Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
[root@localhost /]# ( ./address_to_char;cat) | ./overflow

How does ( ./address_to_char;cat) work here?

What's different from ./address_to_char|./overflow?

share|improve this question
up vote 1 down vote accepted

The outputs of both ./address_to_char and cat are piped to ./overflow as a single, continuous stream of data.

  1. First, ./address_to_char is run, and its output is redirected to ./overflow's input.

  2. When ./address_to_char exits, cat is started, and its output is attached to the still-running ./overflow process in the same way.

    Since cat was run with no files specified, it reads from stdin (in this case, your keyboard).

share|improve this answer
@grawity,when will cat in subshell exit? – kernel Apr 17 '11 at 15:12
@kernel: cat exits upon reaching the end of its input. In this case, it reads from keyboard, and will exit when you press the "EOF" key (by default Ctrl-D). – grawity Apr 17 '11 at 15:17
@grawity,but after testing it seems it will also exit when ./overflow exits,weird...or is that normal? – kernel Apr 17 '11 at 15:18
@kernel: It's normal. When the right side (./overflow) exits, the left side doesn't have anywhere to write to, and -- AFAIK -- gets killed by signal SIGPIPE. – grawity Apr 17 '11 at 15:23
@grawity,that solves most of my doubt,but still one, how can ./overflow get executed before cat exits? – kernel Apr 17 '11 at 15:28

Well the parentheses open a sub shell and the semi colon will run the commands sequentially.

So in this case, you are running ./address_to_char then cat in a subshell.

share|improve this answer
How does the subshell interact with ./overflow? – kernel Apr 17 '11 at 8:53
stderr and stdout are returned and piped into overflow – kband Apr 17 '11 at 9:08
The output of the subshell is then redirected into ./overflow – Troydm Apr 17 '11 at 9:08
It seems there's no difference from ./address_to_char | ./overflow,right? – kernel Apr 17 '11 at 9:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.