LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-10-2013, 01:09 AM   #1
deymrinmoy
LQ Newbie
 
Registered: Jan 2013
Posts: 3

Rep: Reputation: Disabled
Alternative to kill system call using c program to test only process.


Hi,

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.

Thanks
Mrinmoy
 
Old 01-10-2013, 08:58 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,668
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
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.
 
Old 01-10-2013, 08:21 PM   #3
deymrinmoy
LQ Newbie
 
Registered: Jan 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-16-2013, 10:47 PM   #4
deymrinmoy
LQ Newbie
 
Registered: Jan 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi All,

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 .

For example,
#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.

Regards,
Mrinmoy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
intercepting system call / alternative to strace mrshanim Linux - Kernel 2 10-24-2009 09:07 PM
bash `kill`: process 'B' silently dies; but process 'A' = `kill` spews back debris! GrapefruiTgirl Programming 9 06-23-2009 09:42 AM
How to KILL a process or program ? il-uvatar Linux - Newbie 25 05-02-2009 07:59 AM
hey i want to know which command in linux uses the system call kill() vineetnair Linux - Newbie 1 10-02-2007 05:26 AM
i wud like to know which command in linux uses the system call kill() vineetnair Linux - General 1 10-02-2007 04:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration