Reputation: 63
I have a ksh script that calls other scripts. The initial script only makes one call to the second script. However, if I do "ps axwww | grep full_script_name | grep -v grep", it shows 2 instances of the second script, both with different PIDs. And the PIDs are always 4 numbers off from each other (eg 22089 and 22093).
Why is this happening?
Upvotes: 1
Views: 379
Reputation: 62479
First off, it won't always be 4 off, because eventually it will run into some PIDs that are still allocated. But this is probably the scenario, or at least close to it:
script.ksh
- get PID 42script.ksh
calls an external program, which gets PID 43, then exits and returns control to the scriptscript.ksh
calls a second external program, which gets PID 44script.ksh
calls a third external program, getting PID 45script.ksh
calls child-script.ksh
, which gets PID 46, and hangs around while you run ps
"External programs" are numerous - everything from ls
to awk
, sed
, perl
, sort
......
Upvotes: 1