Tag Info

New answers tagged

3

bash-4.3$ ps -j | cat PID PGID SID TTY TIME CMD 4586 4586 4586 pts/1 00:00:00 bash 4600 4600 4586 pts/1 00:00:00 ps 4601 4600 4586 pts/1 00:00:00 cat bash-4.3$ ps -j; ps -j PID PGID SID TTY TIME CMD 4586 4586 4586 pts/1 00:00:00 bash 4602 4602 4586 pts/1 00:00:00 ps PID PGID SID TTY TIME ...


1

The grep process was blocked because it was not getting the EOF from other write end of the pipe.EOF will be send to the reader end when associated write file(fds[1]) descriptors will be closed.My mistake was I didn't closed the write descriptors(fds[1]) from the parent process(main) though I have closed it from process which was writing to the pipe. So the ...


1

parent.py from subprocess import Popen, PIPE cmd = ["python", "child.py"] p=Popen(cmd, stdin=PIPE, stdout=PIPE) for i in range(1,100000): p.stdin.write("hello\n") p.stdin.close() out = p.stdout.read() p.stdout.close() print(out) exitcode = p.wait() child.py import sys l = list() for line in sys.stdin: l.append(line) sys.stdout.write(str(len(l))) ...



Top 50 recent answers are included