mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework

Home Page:https://mojolicious.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Closing stderr causes Mojo app to hang or crash

jjurach opened this issue · comments

  • Mojolicious version: 9.26
  • Perl version: v5.32.1
  • Operating system: Amazon Linux 2022 (like fedora)

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.

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.