Operating System - HP-UX
1833760 Members
2195 Online
110063 Solutions
New Discussion

ksh hangs when execute wait command

 

ksh hangs when execute wait command

Hi,

I have a hanging problem inside a script when we execute a wait command after a sequence of background procesess.

Anyone know a bug on HP-UX 11.11, ksh and wait command ?

Thanks
Xomanet
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: ksh hangs when execute wait command

Well, the wait is supposed to "hang" until all the background tasks have completed (if no argument is supplied) or until a specified background process is finished if a PID is supplied as an argument to wait.

It would probably be helpful if you explained the problem a bit more -- and do you know that the background process(es) have finished?.
If it ain't broke, I can fix that.
Paul Sperry
Honored Contributor

Re: ksh hangs when execute wait command

Some processes in a 2-or-more-stage pipeline may not be children of
the shell, and thus cannot be waited for.
Caesar_3
Esteemed Contributor

Re: ksh hangs when execute wait command

Hello!

Explain more the problem,
add the script that we all could see and help

Caesar

Re: ksh hangs when execute wait command

Hi,

the script wich i have problem is:

------------------------------
cat data1 | while read valor
do
JLSC $valor &
done

wait
------------------------------

after executing and finshing all JLSC processes the script remaing 'waiting' for.

data1 is a file with a list of files to be params of JLSC.

JLSC is a short 'C' program.
Xomanet

Re: ksh hangs when execute wait command

Hi,

sorry, i forgot a important information:
this only occurs sometimes not always !

Xomanet
Bernhard Mueller
Honored Contributor

Re: ksh hangs when execute wait command

Quick question:

how do you generate your data1 file (i.e. your filelist)?

could it be that *sometimes* there are filesnames in it with blanks (from a Samba share or so) or some other characters that make the execution problematic?

to debug you might use set -x or
just echo the command that should be exectued to a logfile.

Regards,
Bernhard
A. Clay Stephenson
Acclaimed Contributor

Re: ksh hangs when execute wait command

There was a subtle bug in the 11.0 ksh that was fixed but that does not apply to 11.11. I would try to run this under the POSIX shell and see if the problem persists. NOTE: In HP-UX /bin/sh (or /usr/bin/sh) is NOT the Bourne shell; it's the POSIX shell. There is really no reason to run the Korn shell because POSIX
is actually a superset of Korn and anything that you can do in the Korn shell, you can do in the POSIX shell. It would be a good thing to know if all of child processes have finished and did they spawn any processes?
If it ain't broke, I can fix that.