ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all,
I need to find out whether a process is alive or it is killed (or zombie), and I would like to know if there is a C function which I could call to get this information. Note that the process I need to check is not a child process of the one which has to "investigate".
Hi all,
I need to find out whether a process is alive or it is killed (or zombie), and I would like to know if there is a C function which I could call to get this information. Note that the process I need to check is not a child process of the one which has to "investigate".
Do you know if such a function exists?
Thank you in advance
hi
this may be helpfull to you
Quote:
ps -A
or
ps -A | grep "processname"
or
ps -fe | grep "processname"
The problem is that ps is a shell command...
I need a function which I could call in a C program. Basically, I have the pid of a process and would like to pass that value to a function and get back "alive" or "error" or something like that.
I think I could use a non-blocking waitpid, but that only works if the process you want to find out about is a child of the calling process...
if ( sigsend (P_PID, n1_id, 0) == 0 )
printf ("Process %d is alive!!\n", n1_id);
I think this should work...if only the linker could find sigsend!!!
This is what it says:
Code:
:main.c:(.text+0x2ed): undefined reference to `sigsend'
I wonder if I have to include some linking options when launching gcc
(as I do with curses.h: -lncurses). If this helps you, I am using Ubuntu 6.06.1 ....
if ( sigsend (P_PID, n1_id, 0) == 0 )
printf ("Process %d is alive!!\n", n1_id);
I think this should work...if only the linker could find sigsend!!!
This is what it says:
Code:
:main.c:(.text+0x2ed): undefined reference to `sigsend'
I wonder if I have to include some linking options when launching gcc
(as I do with curses.h: -lncurses). If this helps you, I am using Ubuntu 6.06.1 ....
Please help me!! This is quite an urgent thing...
mab be it is helpful
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sysexits.h>
I had already included signal.h, but it doesn't work. That's the strange thing: even if signal.h exists and is in the proper place, it seems that the linker can't find it.
The problem remains, but at least I've found another way of doing what I had to do...
I had already included signal.h, but it doesn't work. That's the strange thing: even if signal.h exists and is in the proper place, it seems that the linker can't find it.
The problem remains, but at least I've found another way of doing what I had to do...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.