- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Killing process using C
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
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
тАО07-14-2005 01:59 PM
тАО07-14-2005 01:59 PM
Killing process using C
I would like to kill a process using C, I know the PID so I use:
kill(PID, SIGTSP);
But is it possible to see if this process is valid using C as well? What is the common practise?
Thank u.
Henry
- Tags:
- kill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2005 03:02 PM
тАО07-14-2005 03:02 PM
Re: Killing process using C
By you asking
But is it possible to see if this process is valid using C as well?
Do you mean about the PID? you want to check if its a valid PID? You can do that using the raise() function which actally is used to send signal to a running process and looking at the man pages you see
"If sig is 0 (the null signal), error checking is performed but no
signal is actually sent. This can be used to check the validity of
pid." So before you use the kill function you can call the raise function.
Also why do you want to re-invent a wheel until its a real requirement in your program or a module you are trying to add.
Cheers
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2005 03:46 PM
тАО07-14-2005 03:46 PM
Re: Killing process using C
Thanks for the info, raise() sends signal to itself to its validity, however is there any way i can test process running in the background.
Say i ps -ef and know process A with PID 9081 is running. But after say an hour i want to see if it is still residing in the spool. Is there anyway I can write a procedure in C to test whether this PID is still active... even better if I can see the actual program using this PID...
Best regards
Henry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-14-2005 05:00 PM
тАО07-14-2005 05:00 PM
Re: Killing process using C
so probably not entitled to advise you.
But the common practise (that I also use in Perl scrcipts) is to send the PID as signal 0.
See also "man 2 kill" where they mention the action on receipt of 0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2005 03:32 AM
тАО07-20-2005 03:32 AM
Re: Killing process using C
your system command can either call a script or send the command
ps -ef | grep pid | kill -9 `awk '{print $2}'`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2005 03:39 AM
тАО07-20-2005 03:39 AM
Re: Killing process using C
cc = kill(pid,0);
if (cc == 0)
{
/* valid process */
}
else
{
/* invalid process */
}