Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: problem using $$
- X-seq: zsh-workers 21261
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Rico Schiekel <rico.schiekel@xxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: Re: problem using $$
- Date: Mon, 16 May 2005 02:10:52 +0000
- In-reply-to: <20050513165519.GC11723@xxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050513165519.GC11723@xxxxxxxxxxxx>
On May 13, 6:55pm, Rico Schiekel wrote:
}
} | ps aux | grep " $mp "
} | ps aux | grep "start.osd" | grep -v "grep" | grep -v " $mp "
}
} |b fire 4128 0.0 0.1 2708 1324 pts/4 R+ 18:33 0:00 /bin/zsh ./test.zsh
} |c fire 4172 0.0 0.1 2708 1332 pts/4 R+ 18:33 0:00 /bin/zsh ./test.zsh
}
} - first call:
} why is the process id from the second ps [c] other than the process
} id from the first ps [b] and $$ [a] ?
I think that's because your script is buggy. The third call to grep in
the [c] case should not have the "-v" option.
After getting rid of the stray "-v", try using "ps alx" rather than "aux".
That will allow you to grep the $mp out of both the PID and PPID columns
and thereby see the parent/child relationship among the shells.
} |2 fire 4216 0.0 0.0 0 0 pts/4 R+ 18:33 0:00 [test.zsh]
}
} - second call:
} and what is "[test.zsh]" [2]
The ps output has square brackets like that for a child process when the
original process has fork()ed but has not done an execv() in the child.
This means that the "ps" is running soon enough to catch zsh after it
has forked, but before it has finished starting up one of the greps that
appear later in the pipeline. Vagaries of process scheduling.
} and why has it got another pid (4216) than $$ (4173) [1] ?
Because your script ran 'grep -v " 4173 "'.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author