ios_system
ios_system copied to clipboard
`ios_system` should wait for all commands in line
Example:
echo 'nice' | ssh host
Currently ios_system
exits after first command (echo nice
) and start second command (ssh host).
But we already show blink>
prompt :)
Indeed. I see where the problem comes from, but the solution is not obvious. Commands should wait for all commands they have started (either with pipe or fork/exec/system), but not for the others. Making sure the command is not blocked by a command in another terminal is the tricky bit.
I'm going to think about it.
I think this is related issue blinksh/blink#637
May by whole ios_system should be as meta program...
The two issues were not related, but I have committed a fix for blinksh/blink#637
I'm not sure what you mean by meta program; would you have a pointer to some documentation?
Fix committed for this issue (f10015f).
It was a bug I introduced with a recent change (introduction of pthread_detach
at line 1390 of ios_system.m
). We've now reverted to the previous behaviour:
- wait for the first command in the pipe to terminate (with
pthread_join
) - then wait for the last command in the pipe to terminate (with
pthread_join
too) Which works for these commands, and for multiple pipes too.
The mistake I made was that once a thread has been detached, it cannot be joined again. Now, we don't detach the last command in the pipe, so we can join it later.
Good catch. Ignore my meta program thing :)
Will try it tomorrow
Thank you
Works for me. Thank you!
echo nice | ssh office cat
somehow try to run office cat
as command.
ssh is using getopts
to parse args, how can I use getopts from ios_system?
If I add sleep(1);
before parsing args it works as expected :)
Hmmm.... that's odd.
For a test, I copied getopts from ios_system and make all vars with thread_ prefix. And it works.