- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: trap process id
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
Discussions
Discussions
Forums
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
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
тАО08-01-2001 09:34 AM
тАО08-01-2001 09:34 AM
Here is the situation. I need to recover the PID of a program I launched in background (from a script). Other scripts may have launched the same program so a simple ps | grep command wouldn't do the job. I feel unsure with the $! command (witch return the PID of the last background program that has been launched) because two script could launch background programs at the same time and then, I can't be sure I got the PID of my program. I also heard about the ps -H but it only applies for XPG4. Any ideas?
Thanks for your help...
Dom
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2001 09:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2001 09:55 AM
тАО08-01-2001 09:55 AM
Re: trap process id
While pid values will eventually be reused (when they are no longer in use), there is no problem with capturing a pid in a variable and later referencing/testing it.
See this recent thread for some examples:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0xfe7387dc4d7dd5118ff00090279cd0f9,00.html
ALSO: if you want to leverage the UNIX95 options of 'ps' all you need do is arm the UNIX95 variable for the duration of the 'ps' like this (your offering):
UNIX95= ps -H
Note the blank character after the equal sign and the absence of any semicolon! This syntax sets UNIX95 only for the command on the line it is written.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2001 10:02 AM
тАО08-01-2001 10:02 AM
Re: trap process id
It doesn't matter if another process also spawns a process of the same name. $! will definitely be the pid of the last background child process spawned by this shell.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-01-2001 10:37 AM
тАО08-01-2001 10:37 AM
Re: trap process id
I'm now a happy camper :-)