Skip to main content
Commonmark migration
Source Link

run a pipe cmd1 | cmd2 n such a way that:

 

cmd2 doesn't start running until cmd1 has completely finished

This is impossible in general. Read pipe(7) which reminds you that pipes have limited capacity (typically 4Kbytes or 64Kbytes) and they use some kernel memory for their buffer.

So the output of cmd1 goes into the pipe. When it becomes full, any write(2) done by cmd1 to STDOUT_FILENO would block (unless cmd1 is specially coded to handle non-blocking I/O to stdout, and this is very unusual) until cmd2 has read(2) from that pipe other's end. If cmd2 did not start, that would never happen.

I strongly recommend reading a book like Advanced Linux Programming which explains that in details (and an entire book is needed to explain all this).

run a pipe cmd1 | cmd2 n such a way that:

 

cmd2 doesn't start running until cmd1 has completely finished

This is impossible in general. Read pipe(7) which reminds you that pipes have limited capacity (typically 4Kbytes or 64Kbytes) and they use some kernel memory for their buffer.

So the output of cmd1 goes into the pipe. When it becomes full, any write(2) done by cmd1 to STDOUT_FILENO would block (unless cmd1 is specially coded to handle non-blocking I/O to stdout, and this is very unusual) until cmd2 has read(2) from that pipe other's end. If cmd2 did not start, that would never happen.

I strongly recommend reading a book like Advanced Linux Programming which explains that in details (and an entire book is needed to explain all this).

run a pipe cmd1 | cmd2 n such a way that:

cmd2 doesn't start running until cmd1 has completely finished

This is impossible in general. Read pipe(7) which reminds you that pipes have limited capacity (typically 4Kbytes or 64Kbytes) and they use some kernel memory for their buffer.

So the output of cmd1 goes into the pipe. When it becomes full, any write(2) done by cmd1 to STDOUT_FILENO would block (unless cmd1 is specially coded to handle non-blocking I/O to stdout, and this is very unusual) until cmd2 has read(2) from that pipe other's end. If cmd2 did not start, that would never happen.

I strongly recommend reading a book like Advanced Linux Programming which explains that in details (and an entire book is needed to explain all this).

Source Link

run a pipe cmd1 | cmd2 n such a way that:

cmd2 doesn't start running until cmd1 has completely finished

This is impossible in general. Read pipe(7) which reminds you that pipes have limited capacity (typically 4Kbytes or 64Kbytes) and they use some kernel memory for their buffer.

So the output of cmd1 goes into the pipe. When it becomes full, any write(2) done by cmd1 to STDOUT_FILENO would block (unless cmd1 is specially coded to handle non-blocking I/O to stdout, and this is very unusual) until cmd2 has read(2) from that pipe other's end. If cmd2 did not start, that would never happen.

I strongly recommend reading a book like Advanced Linux Programming which explains that in details (and an entire book is needed to explain all this).