[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exec vs. source spawning piped commands

From: Greg Wooledge
Subject: Re: exec vs. source spawning piped commands
Date: Thu, 22 Sep 2011 08:24:31 -0400
User-agent: Mutt/

On Wed, Sep 21, 2011 at 01:09:32PM -0400, Pete Nelson wrote:
> I'm confused about what exec is doing in this case.
> Sample script t:
> #!/bin/bash
> echo $0 pid: $$ ppid: $PPID args: $* 1>&2
> if [ -z "$1" ]; then
>   exec $0 first | $0 second
>   echo should not reach here
> fi

It does nothing.  The $0 command being executed inside the subshell
created by the pipeline is *already* being "exec"ed.

> My intention is to give the second piped process the ability to send signals
> to the first using its $PPID variable.

mkfifo myfifo
first > myfifo & first=$!
second $first < myfifo &   # Pass PID of first as an argument
rm myfifo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]