Timeline for Notification Listener Behaving Strangely when Backgrounded
Current License: CC BY-SA 3.0
24 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 11, 2020 at 12:04 | history | edited | CommunityBot |
Commonmark migration
|
|
| S Sep 3, 2015 at 4:28 | history | bounty ended | CRThaze | ||
| S Sep 3, 2015 at 4:28 | history | notice removed | CRThaze | ||
| Sep 3, 2015 at 4:28 | vote | accept | CRThaze | ||
| Sep 2, 2015 at 21:57 | answer | added | zackse | timeline score: 1 | |
| Sep 1, 2015 at 14:32 | comment | added | zackse |
Try adding -d to the nc command, which will prevent nc from attempting to read from stdin. In the second case above, where you background the function, stdin is closed before the pipeline is created. The result is that on the first poll, nc reads EOF from stdin and closes fd 0. The next call to accept yields a client on fd 0. After that client disconnects, nc gets into an endless loop as it attempts to poll repeatedly on the closed fd 0 (which it thinks is stdin, which should never close). In the first command, stdin is left open, so this case doesn't arise.
|
|
| S Aug 30, 2015 at 17:45 | history | bounty started | CRThaze | ||
| S Aug 30, 2015 at 17:45 | history | notice added | CRThaze | Draw attention | |
| Aug 30, 2015 at 17:25 | history | edited | CRThaze | CC BY-SA 3.0 |
expanding tl;dr
|
| Aug 30, 2015 at 8:21 | history | tweeted | twitter.com/#!/StackUnix/status/637902881526542336 | ||
| Aug 28, 2015 at 22:30 | history | edited | CRThaze | CC BY-SA 3.0 |
Added repro instructions and strace output observations.
|
| Aug 28, 2015 at 22:28 | comment | added | CRThaze | Edited question to include these further test results along with repro. steps. | |
| Aug 28, 2015 at 22:25 | history | edited | CRThaze | CC BY-SA 3.0 |
Added repro instructions and strace output observations.
|
| Aug 28, 2015 at 21:16 | comment | added | CRThaze |
OK. So I reproduced this behavior after removing SSH from the picture and doing everything locally—which resulted in cleaner strace output. I ran two versions of this test script with strace -f; one which backgrounded the piped expression and would process unlimited test messages (pastebin.com/GDjxTJuJ), and one which backgrounded a wrapping function and which only processed two messages before breaking (pastebin.com/GMtkKefP). The strace -f output of these respective scripts was 1) pastebin.com/SMjti3qW, and 2) pastebin.com/WsrXX0EJ
|
|
| Aug 28, 2015 at 18:08 | comment | added | CRThaze |
adding -f to the nc strace doesn't have any effect, since nc does not fork at all. I'd give you the full output of running that on the client-side script, but what this provides is so long and contains so much sensitive information (from LDAP, etc.) that I can't properly sanitize to paste here. But I can tell you that, what I always observe when I try this that two messages are always passed through, but the last one does not appear to be properly terminated (it's missing a new-line character) or something, and that seems to coincide with when nc starts spewing poll() messages.
|
|
| Aug 27, 2015 at 0:42 | comment | added | zackse |
Can you paste the output of strace -f ? That will follow forks to include traces from all subprocesses spawned.
|
|
| Aug 26, 2015 at 21:58 | comment | added | CRThaze |
adding -n to ssh seems to have the same effect as any other attempt to close STDIN (two and done behavior). As does closing STDIN on the subprocess. I ran strace on nc though, and it does show some interesting behavioral differences between scenarios where all messages get through (pastebin.com/tCSwtA99), and when only two get through (pastebin.com/gZueVpb0). I'm not the best at reading strace output. I may have to dig through some system call documentation to make sense of this.
|
|
| Aug 25, 2015 at 15:43 | answer | added | Onnonymous | timeline score: 1 | |
| Aug 21, 2015 at 18:42 | comment | added | zackse |
Note that ssh -n will prevent reading from stdin, though this doesn't seem to be the cause of the main issue. What does strace of the nc process show when compared to the subprocess? Is nc receiving and emitting data? Is it blocking? Does closing stdout for the subprocess have any effect?
|
|
| Aug 20, 2015 at 20:55 | history | edited | CRThaze | CC BY-SA 3.0 |
deleted 1 character in body
|
| Aug 20, 2015 at 20:45 | history | edited | CRThaze | CC BY-SA 3.0 |
Adding some other tests I've tried and formatting. As well as adding a tl;dr summary.
|
| Aug 20, 2015 at 20:40 | history | edited | CRThaze | CC BY-SA 3.0 |
Adding some other tests I've tried and formatting. As well as adding a tl;dr summary.
|
| Aug 20, 2015 at 20:23 | history | edited | CRThaze | CC BY-SA 3.0 |
added 446 characters in body
|
| Aug 20, 2015 at 20:09 | history | asked | CRThaze | CC BY-SA 3.0 |