<div dir="auto">Can we use /dev/ptmx to get a pty and use that? I'll try that in the PST morning if you haven't done it yourself or explained why it doesn't work by then ðŸ˜€</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 23, 2020, 20:43 Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 1/22/20 11:02 PM, enh via Toybox wrote:<br>
> The commit that added the read mentioned the killall tests, but they use<br>
> sleep. Blocking on a read of stdout is failing in some of the Android<br>
> test infrastructure where it seems to end up connected to a socket.<br>
> <br>
>  Â ./pidof-12488.test[2]: can't open /proc/self/fd/1: No such device or address<br>
<br>
Sleep was spawning a child process, which meant it would fork() another instance<br>
of the same process before calling exec(), and thus kill and such were reporting<br>
multiple processes matched if they happened at exactly the wrong time, which was<br>
intermittently breaking your testing.<br>
<br>
That's why I changed it. You're reintroducing the old problem. I don't see how<br>
we can fork() without that window. (Now maybe we can have a LONG pause to let<br>
the fork flush through, but that's a question of the system you're running it on?)<br>
<br>
And we can't do the "ln -s $(which sleep) spleep" trick because we're<br>
specifically checking the "/bin/bash script.sh matches script.sh" part of the<br>
plumbing here, so it has to have an interpreter...<br>
<br>
Oh: Maybe we could #!/bin/sleep and then call the script "10". :)<br>
<br>
$ echo -e '#!'"$(which sleep)\nblah\n" > 10; chmod +x 10; ./10<br>
/bin/sleep: invalid time interval â€˜./10’<br>
Try '/bin/sleep --help' for more information.<br>
<br>
Hmmm...<br>
<br>
$ echo -e '#!'"$(which sleep)\nblah\n" > 10; chmod +x 10; PATH=":$PATH" 10<br>
/bin/sleep: invalid time interval â€˜./10’<br>
Try '/bin/sleep --help' for more information.<br>
<br>
Seriously? That's really how you're gonna play this bash?<br>
<br>
Sigh, skip all the previous ratholes I've been down ("wait" can't take an<br>
arbitrary PID only an existing child process, and wait -n with no children<br>
returns immediately...)<br>
<br>
Sadly, when debian's "flock" says it can take a filename in its man page:<br>
<br>
  $ cat blah<br>
  #!/usr/bin/flock<br>
  true<br>
  $ flock blah -c ./blah<br>
  flock: bad file descriptor: './blah'<br>
<br>
<br>
it lies. (And toybox never implemented the non-fd stuff anyway; no idea why it<br>
implemented the _fd_ stuff but clearly somebody wanted this...)<br>
<br>
Sigh, I can "yes > /dev/null" but that's a CPU eating loop if it doesn't work<br>
and I hate leaving those around as debris.)<br>
<br>
How about:<br>
<br>
  tty -s && skip_test<br>
  blah < /dev/tty<br>
<br>
Which is a sad aribtrary limitation I don't like but would at least probably<br>
skip the test entirely on your irreproducible test environment?<br>
<br>
I can create a dedicated C program to act as the test?<br>
<br>
(Sigh, why couldn't we trust a read from stdin to block again? Just running<br>
"cat" would give us something to kill that doesn't eat CPU if we don't. I think<br>
one of your test containers was broken with that, but I forget?)<br>
<br>
Rob<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank" rel="noreferrer">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div>