LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   When does a PIPE open the next process? (https://www.linuxquestions.org/questions/linux-newbie-8/when-does-a-pipe-open-the-next-process-949055/)

CarT_0x41414141 06-07-2012 12:43 PM

When does a PIPE open the next process?
 
When does a linux pipe open the next program in the command...

Example command #1
python -c 'raw_input(); print "AAAA"' | netcat localhost 31337

What is the long version of a pipe '|' ?
defclare new fd xyz
command1 1>&xyz; run commdand < &xyz ?

Thanks in advance

Doc CPU 06-07-2012 03:57 PM

Hi there,

Quote:

Originally Posted by CarT_0x41414141 (Post 4698028)
When does a linux pipe open the next program in the command...

Example command #1
python -c 'raw_input(); print "AAAA"' | netcat localhost 31337

AFAIK, the shell first creates a pipe, then creates the two processes (python and netstat) nearly simultaneously, passes the write end of the pipe to the first process (python), and the read end to the second process (netstat). So the two programs run concurrently at the same time, output of one becoming input of the other.

Quote:

Originally Posted by CarT_0x41414141 (Post 4698028)
What is the long version of a pipe '|' ?

I'm not sure I understand the question. And I don't know much of python. Almost nothing, to be honest.
Anyway, the strategy must be:
  1. open a pipe
  2. create the first process, passing it the pipe's file descriptor as stdout
  3. create the second process, passing it the pipe's file descriptor as stdin
This is abstract enough to be appropriate to nearly any language that offers functions for process control.

[X] Doc CPU


All times are GMT -5. The time now is 03:41 AM.