mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.67k stars 580 forks source link

Closing stderr causes Mojo app to hang or crash #2028

Closed jjurach closed 1 year ago

jjurach commented 1 year ago

I realize that closing stderr was generally a bad thing for me to do, but I wouldn't expect accidentally doing that would cause Mojolicious to hang for 40 seconds. Hanging (and possibly crashing) like this is a severe and unexpected consequence of this accident. Not sure what a better behavior would be, other than exiting more quickly with some oddball exit status which might stand out in Mojolicious source code.

Steps to reproduce the behavior

mojo generate lite-app
# edit    close(STDERR);   into myapp.pl
./myapp.pl get /foo

Expected behavior

The sample app should write the rendered response to stdout, without logging to stderr.

Actual behavior

The sample app hangs for 40 seconds and then produces no response.

kraih commented 1 year ago

Just don't close STDERR, best practice is to reopen it to /dev/null if you really don't care about it. That said, i'd always want STDERR output in my systemd journal.