It is currently Tue, 30 Nov 2021 18:28:48 GMT



 
Author Message
 obtaining child PID in a child subshell

Is there anyway to do the following:

I want some way of determining what the process ID is when in a
subshell.  Having $$ somehow returning the *real* child process
would be one solution, but I don't see how to make that work.

Here is a sample scenario:

set_context(){
    if test $$ -ne ${CONTEXT:?}
    then
        CONTEXT=$$
        BLOCK=1
        SEQUENCE=1
    fi

set_context
echo context $CONTEXT...mess1
echo context $CONTEXT...mess2

(set_context
echo context $CONTEXT...mess1
echo context $CONTEXT...mess2
)

set_context
echo context $CONTEXT...mess3

(set context
echo context $CONTEXT...mess1
echo context $CONTEXT...mess2
)

set_context

echo context $CONTEXT...mess4

----

Ideally, you would have mess1-4 in 1 context, and 2 more copies of
mess1-2 in separate contexts.  What you get is three copies of mess1-2 in the
parent's context (along with mess3-4).

Constraints:  it must be shell or common shell utils (awk, sed, cat, tr etc.)
        only.  It must be fairly portable across different Unix versions.

william

--

:: If pro-choice means choice after conception, does this apply to men too?  ::
:: If choice is made solely by the woman, then shouldn't the responsibility  ::
::    be borne solely by the woman?     With choice comes responsibility.    ::



 Wed, 28 Feb 1996 04:21:19 GMT   
 
   [ 1 post ] 

Similar Threads

1. Getting a child and child's child process-id

2. Getting a child and child's child process-id

3. what is parent shell, child shell and subshell, ?

4. Obtaining results from multiple child processes

5. Obtaining pids of children

6. Obtaining KSH environment variables from child process?

7. how do i wait for child processes, and *their* children to finish

8. signals: stop child, parent told child died !


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software