DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 22nd October 2008
techmarks techmarks is offline
New User
 
Join Date: Jun 2008
Posts: 5
Thanked 0 Times in 0 Posts
Default sigint form within a c prog

How do I send the kill signal to a program from within another program?

I understand I can do this

Code:
kill (pid, SIGINT);
]

But how do I get the pid for the program I want to kill from within the program I want to issue the signal from?

Thanks for any information.
Reply With Quote
  #2   (View Single Post)  
Old 22nd October 2008
mdh's Avatar
mdh mdh is offline
Real Name: Matt D. Harris
FreeBSD 2.2.6 User
 
Join Date: Oct 2008
Location: West Virginia
Posts: 139
Thanked 8 Times in 8 Posts
Default

The best tutorial is probably the /usr/src/bin/ps source code...

There's also /proc, but that isn't as portable, as not every system always mounts /proc (OK, most don't nowadays.)

Generally speaking, you'll need to hit the kvm_* calls, which are documented in man pages, but reading the ps source is probably the easiest way to figure out what's up and see it in action before diving into the man pages to make sure you get your implementation right.
Reply With Quote
  #3   (View Single Post)  
Old 22nd October 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

are the 2 processes related in some way or are you just killing some unrelated process?

maybe checkout the source code for the ptools pgrep or pkill?
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick