![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question on order of headers and WEXITSTATUS | frequency8 | High Level Programming | 5 | 06-05-2007 10:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
[SOLVED] C - WEXITSTATUS() question
I want to check if an application is still running under C. So far I've been using
Code:
int rc;
rc=WEXITSTATUS( [PID here] )
if(rc > 0)
{
//then I exited
}
Last edited by james2432; 10-19-2009 at 09:40 AM.. |
|
||||
|
Code:
pid_t waitpid(pid_t pid, int *status, int options); // use WNOHANG as the option ---------- Post updated at 11:48 ---------- Previous update was at 11:00 ---------- If it is not a child process - try Code:
errno=0;
if(kill(pid, 0) == 0 )
{
printf("process running\n");
}
else
{
if(errno==ESRCH)
printf("process stopped\n");
else
{
perror("cannot signal the process");
exit(1);
}
}
|
|
||||
|
The thing is I'm creating a daemon to check that certain applications are running(via PID) I do not initially launch them(so they are not my children) and I don't really feel like trying to kill something that I'm to prevent from stopping. would waitpid still work even though it's not my child?
|
![]() |
| Bookmarks |
| Tags |
| c language, wexitstatus() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|