Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 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? Commented Aug 21, 2015 at 18:42
  • 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. Commented Aug 26, 2015 at 21:58
  • Can you paste the output of strace -f ? That will follow forks to include traces from all subprocesses spawned. Commented Aug 27, 2015 at 0:42
  • 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. Commented Aug 28, 2015 at 18:08
  • 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 Commented Aug 28, 2015 at 21:16