On Sun, 12 May 2024 03:55:21 +0200
Quốc Trị Đỗ <quoctr...@gmail.com> wrote:

> Hi,
> 
> I found a bug when i tried with syntax <(cmd). this is an example
> cat <(wc -l) < bk
> 
> You can follow this command, then you have bugs. I think because you
> created a fork getting inside in the parenthesis and the main process do <
> bk. They work parallel. Because of that,  yeah.
> At least, I tried this here on this campus, at 42Heilbronn - Germany.
> 

Let's replace wc with ps for a moment.

$ cat <(ps -j)
    PID    PGID     SID TTY          TIME CMD
   7840    7840    7840 pts/0    00:00:00 bash
   8492    7840    7840 pts/0    00:00:00 ps
   8493    8493    7840 pts/0    00:00:00 cat

There, cat ends up being the sole member of the foreground process group (whose 
PGID happened to be 8493 at the time). It can be seen that ps is not a member 
of that same process group. Were ps to try to read from the standard input - as 
wc does - it would also fail. The reason is that only processes belonging to 
the foreground process group are allowed to read from the controlling terminal.

> How to fix it? It doesn't last that long. After a while, it will show "wc:
> stdin: read: Input/output error". Or we can ctrl C.
> Version 5.2

Though already asked, what were you intending for it to do?

-- 
Kerin Millar

Reply via email to