parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting stdout


From: Ole Tange
Subject: Re: Detecting stdout
Date: Thu, 14 Apr 2016 23:16:10 +0200

On Tue, Apr 12, 2016 at 2:28 AM, Kip Warner <kip@the
:
> Something strange though happened during the migration. Previously
> my_program was able to detect correctly when the standard out device
> was an actual terminal via a call at runtime to isatty(STDOUT_FILENO).
>
> I noticed with GNU parallel, however, this same function seems to
> report a terminal is not open for stdout even when it is. Is this a bug
> in GNU parallel? Or more likely I am doing something wrong.

xargs keeps the tty open for the program.

GNU Parallel runs multiple in parallel, so for a while GNU Parallel
gave the tty to the first job, and to the first job started after it
was released. This was highly unpredictable and caused user to scratch
their head losing too much of their sparse hair.

So this behaviour was changed.

Now no tty is given unless you use --tty which activates the old behaviour:

  seq 100 | parallel --tty -j+0 --group -qn1  -I {} perl -e
"sleep({});print -t,\"\\n\""

--tty implies -u and -j1, so if you want multiple jobs with grouped
output you need to override that (as above).

You can also force every process to read from/write to the tty with
'</dev/tty >/dev/tty':

  seq 100 | parallel -n1 -I {} 'perl -e "sleep({});print -t,\"\\n\""
</dev/tty >/dev/tty'

When using buffered output (--group/--linebuffer) then STDOUT is
buffered into a file and that is probably what your program sees.


/Ole



reply via email to

[Prev in Thread] Current Thread [Next in Thread]