[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detecting stdout
From: |
Kip Warner |
Subject: |
Re: Detecting stdout |
Date: |
Thu, 14 Apr 2016 14:28:39 -0700 |
On Thu, 2016-04-14 at 23:16 +0200, Ole Tange wrote:
> 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.
Thanks Ole. In my case my program fortunately has a way to manually
override detection of a tty. It is useful for when autodetection fails
in determining whether VT100 colours are supported. This is how GNU ls
works as well via isatty(STDOUT_FILE_NO).
--
Kip Warner -- Senior Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com
signature.asc
Description: This is a digitally signed message part