Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Nov 2011 15:45:51 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Mark Saad <nonesuch@longcount.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: What is going on with ash / sh
Message-ID:  <20111102204551.GU93709@dan.emsphone.com>
In-Reply-To: <20111102204002.GT93709@dan.emsphone.com>
References:  <CAMXt9NYcO4JsZRUr_TVzoE08F7hyED4EUM5RBH2w6gC5_NSe5Q@mail.gmail.com> <20111102204002.GT93709@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Nov 02), Dan Nelson said:
> In the last episode (Nov 02), Mark Saad said:
> > Hackers
> >  What is going on here, if I run the following shell script, what is
> > the expected output . The script is named xxx
> > 
> > #!/bin/sh
> > ps -ax | grep -v grep | grep xxx
> > 
> > Here is what I see
> > 
> >  # sh xxx
> > 88318  p0  S+     0:00.00 sh xxx
> > 88320  p0  R+     0:00.00 sh xxx
> > 88321  p0  R+     0:00.00 sh xxx
> > 
> > Can someone explain this ?
> 
> What does your script do?  If it contains subshells or pipelines, the main
> process will fork child processes to handle those.

Sorry; I misread your original post.  Yes, that script forks off two
subshells to handle the pipeline, and the ps command caught the state where
the subshells had been created but had not yet exec'ed their grep commands.

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111102204551.GU93709>