- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- using "wait PID" with >1 background process
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 07:00 AM
02-22-2001 07:00 AM
wait PID seems to work OK if there's only one background job executed
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2001 07:10 AM
02-22-2001 07:10 AM
SolutionAlong the same lines as my response from your first post, run this:
#!/usr/bin/sh
#
/tmp/sh 1 &
P1=$!
/tmp/sh 2 &
P2=$!
#
echo "doing other work..."
sleep 10
echo $?
#
wait $P1
R1=$?
if [ "$R1" -ne 0 ]
then
echo "$P1 cannot continue $R1"
else
echo "$P1 ok $R1"
fi
#
wait $P2
R2=$?
if [ "$R2" -ne 0 ]
then
echo "$P2 cannot continue $R2"
else
echo "$P2 ok $R2"
fi
#
#_end.
#!/usr/bin/sh
#
#...this is /tmp.sh
sleep 2
exit $1 # return what was passed
#
#_end.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2001 06:54 AM
02-23-2001 06:54 AM
Re: using "wait PID" with >1 background process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2001 07:01 AM
02-23-2001 07:01 AM
Re: using "wait PID" with >1 background process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2001 08:21 AM
02-24-2001 08:21 AM
Re: using "wait PID" with >1 background process
e.g.
at a shell prompt:
$ sleep 10 &
which kicks off sleep in background
Now immediately enter
$ wait $!
when the wait returns enter:
$ echo $?
and you get a sensible return code
But try this:
$ sleep 10 &
which kicks off sleep in background
Now wait for 15 seconds, and then enter
$ wait $!
which will return immediately, then enter:
$ echo $?
and don't get a sensible return code!
This is a obviously an 'engineered' scenario, but this has caught me out in a script that 'waited' for a bunch of compresses to complete. The compresses exited immediately due to a badly constructed path name, but I spent ages looking for the odd return code I got out of wait!
I am an HPE Employee
