On Sun, Jun 25, 2017 at 12:14 PM, Rob Landley <r...@landley.net> wrote: > > > terminal1$ echo foo | toybox nc -l -p 1234 > bar > > terminal1$ cat bar > > bar > > Your call there wouldn't work with the "stop after -l" version either, > the -p would have to come before the -l. :P
Seems to work for me? > > terminal2$ echo bar | toybox nc localhost 1234 > foo > > terminal2$ cat foo > > foo > > Um... yes? That's what it's supposed to do, and what it's doing without > this patch? > > Your first hunk told it to run an instance of netcat in chat mode (no > command to run, so instead stdin and stdout of netcat get forwarded to > the connection). This will block until the connection is made, although > if you're redirecting the input you can background it if you want to. > > The second hunk then made a connection. The "bar" you wrote to the > second instance got written to the first instance's output, and the > "foo" you wrote to the first instance got forwarded to the second > instance's output. When each instance gets EOF from stdin it calls > shutdown(fd) to let the other instance know, so both instances exit. > > I just built netcat from clean toybox, and it did that. I don't see the > problem? > That's not what I'm seeing. With a freshly compiled tip of tree master (279eb227), the listener doesn't ever exit: # Terminal 1 jmgao@cyclops2:/android/upstream/toybox$ echo foo | ./toybox nc localhost 1234 foo jmgao@cyclops2:/android/upstream/toybox$ echo bar | ./toybox nc localhost 1234 jmgao@cyclops2:/android/upstream/toybox$ echo baz | ./toybox nc localhost 1234 jmgao@cyclops2:/android/upstream/toybox$ # Terminal 2 jmgao@cyclops2:/android/upstream/toybox$ echo foo | ./toybox nc -l -p 1234 foo bar baz ^C jmgao@cyclops2:/android/upstream/toybox$ `toybox nc -l -p 1234 echo foo` works fine because the process execs without forking. Using -l without a command will fall through to pollinate, finish, and then try to listen again.
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net