Alternative to kill system call using c program to test only process.
I am using kill(pid,0) using c program to test a process on linux. But there is no pid exists & another process has same thread id. Hence kill return success. But I am looking for similar api that checks only process level with similar performance like kill. Can any one please help on this.
You have to provide the correct PID. "kill" actually sends a signal to a process and it must be correctly told which process to send the signal to. You can't get around that.
pid provided to kill is proper. kill on linux behaves as I mentioned earlier. My purpose to test a process(pid) dead or running. Now if the process(pid) dead and later there in another process(pid1) started which has a thread id as pid. Now if we do kill for pid, it returns success.
To give more details about the behavior on kill on Linux. We can find any multi-threaded process and call kill 0 for any thread of it. For Linux, kill 0 returns success for that thread. But for other UNIX, kill 0 could not find that thread .
#ps -eaf|grep automount
root 2480 1 0 Jan02 ? 00:00:11 automount
#pstack 2480 |grep -i LWP
Thread 5 (Thread 0x41e37940 (LWP 2481)):
Thread 4 (Thread 0x41e48940 (LWP 2482)):
Thread 3 (Thread 0x42849940 (LWP 2485)):
Thread 2 (Thread 0x412a2940 (LWP 2488)):
Thread 1 (Thread 0x2b5ed7783af0 (LWP 2480)):
On Linux, Kill(0,2485) finds, but for other UNIX it does not find.
It seems that kill(0,pid) first search pid for process , if process does not exists with that id, then it goes till thread level.
Please let me know any alternative or I can restrict to test process by pid till process level.
Many thanks in advance.
|All times are GMT -5. The time now is 04:02 AM.|