Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process suspended when stdout and stderr are redirected and the process is daemonized #172

Closed
vickychijwani opened this issue Apr 24, 2017 · 3 comments

Comments

@vickychijwani
Copy link

Here's a shell session demonstrating the issue:

$ serve -s . >/dev/null 2>&1 &
[1] 31586
# after a couple of seconds, this message is displayed:
[1]  + 31586 suspended (tty output)  serve -s . > /dev/null 2>&1

# checking process status... output edited for readability
$ ps gv | grep serve
32623 pts/28   TNl    0:00      0 24425 898230 42720  0.2 node <some_path>/serve -s .

# the "T" in "TNl" above means the process is "stopped, either by a job control signal or because it is being traced."
# for details, go to https://linux.die.net/man/1/ps and Ctrl-F "process state codes"

# at this point, opening the link in the browser produces no response (connection stalls)

# however, all of these combinations work just fine:
$ serve -s . &                     # neither stdout nor stderr redirected
$ serve -s . >/dev/null &          # stderr not redirected
$ serve -s . 2>/dev/null &         # stdout not redirected
$ serve -s . 1>/dev/null 2>&1      # not backgrounded

As you can see, the issue only occurs if all 3 of the following conditions hold:

  1. stdout is redirected (>/dev/null or 1>/dev/null)
  2. stderr is redirected (2>/dev/null or, more commonly, 2>&1)
  3. the process is sent to the background (trailing &)
@vickychijwani vickychijwani changed the title Serve process gets suspended when stdout and stderr are supressed and the process is daemonized Process suspended when stdout and stderr are redirected and the process is daemonized Apr 24, 2017
@pablopunk
Copy link
Contributor

This should be fixed once boxen uses a new binary for getting the window size.

See issue sindresorhus/terminal-size#3 (comment)

@pablopunk
Copy link
Contributor

Updating the dependencies (npm install) should fix this but now although the process is not stopped immediately, it doesn't run the server (if you go to http://localhost:5000 it never loads)

@leo
Copy link
Contributor

leo commented Jun 20, 2017

Already updated to the latest boxen!

@leo leo closed this as completed Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants