tags:

views:

53

answers:

1

So.. I use KSH on Solaris8 for quite long but this is the first time I got something like this:

I start a script - let's call it splitCfg. When I call pgrep -x splitCfg I'm finding two instances of this script - the main instance and a child of my script (output from ps):

root 28069 25107  0 20:22:01 pts/10   0:00 splitCfg
root  4668 28069  0 20:22:50 pts/10   0:00 splitCfg

As you can see - the first instance is a parent for a child. However - there is no subprocess created from the main script. When I call the ps or pgrep or ptree one more time I get: 1. no child process or 2. a new child process

I am looking for some explanation. I believe I've search whole Internet, so it's time to ask all of you for some of your precious time :)

Is it some sort of the KSH bug (note that I'm using pretty old version from Solaris 8) or am I missing something. I understand that single script should create a single PID and leave it when it finishes.

Thanks, Saperzasty

+1  A: 

If you have parenthesis in your shell script, the subshell may run in a separate Unix process, depending on what ksh version you have. I think ksh88i (a very old version) is still shipping as the system shell on Solaris.

Norman Ramsey
Norman, thanks! This is what I was looking for. I am using:numInstances=$(/bin/pgrep -x ${CMD} | /bin/wc -l)to get number of running instances of my script (I want only single instance at a time). CMD is a basename of ${0}. This appears only when server is heavily loaded so your suspicions are correct.I have split this in two parts and now I get correct number.Thank you
Patryk Baranowski

related questions