- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Child process passing parent a status code
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
07-28-2003 10:24 AM
07-28-2003 10:24 AM
Child process passing parent a status code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 10:33 AM
07-28-2003 10:33 AM
Re: Child process passing parent a status code
exit 0
for good status codes
return 1
exit 1
for bad.
There is a system for the various codes if you want to be all official.
The methodology above passed the code back from the child to the parent, if the parent is waiting. Whether or not this works depends on how the child was launched.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 10:34 AM
07-28-2003 10:34 AM
Re: Child process passing parent a status code
One option is to use the wait command.
child.sh &
CHILDPID=${!}
...
...
...
wait ${CHILDPID}
The wait will block until the child finished and report its status.
Trying to export a variable from the child to the parent absolutely will not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 10:39 AM
07-28-2003 10:39 AM
Re: Child process passing parent a status code
Thanx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 10:53 AM
07-28-2003 10:53 AM
Re: Child process passing parent a status code
1) Capture the child pid using ${!}.
child.sh &
CHILDPID=${!}
The child will write its status to a temp file
based upon it's process ID ${$}.
e.g. /var/tmp/X${$}.txt
and just before exiting send a signal to its parent process using ${PPID}.
e.g. kill -s 16 ${PPID}
The parent would have a trap on signal 16 (or the agreed upon signal) to then read /var/tmp/X${CHILDPID}.txt for the status information and then remove the temp file.
This will give you a mechanism for asynchronously handling multiple child processes while continuing to do useful task in the parent. All the child processes could share a command signal but the operation should be quick so that no signals are ignored while processing an existing one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 12:54 PM
07-28-2003 12:54 PM
Re: Child process passing parent a status code
Thanx Again
Brian Pyle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2003 03:16 AM
07-29-2003 03:16 AM
Re: Child process passing parent a status code
the exit-Status of the 'wait'-command is that of the child, so:
child &
wait $!
child_exit=$?
Peter