LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-01-2003, 05:49 PM   #1
Linh
Member
 
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
C code for killall function


C code for killall function

What is the C code equivalent for this bash code below
killall smbd

In C code, I can only find this
kill (pid, SIGTERM)

I know how to search for a process name and find its pid to shut down a process, but is there a killall function in C code as in
killall (pid, SIGTERM) ?
 
Old 08-01-2003, 05:56 PM   #2
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
Try reading the source of killall, or how to execute shell commands via C.
 
Old 08-01-2003, 06:04 PM   #3
jemfinch
LQ Newbie
 
Registered: Jul 2003
Location: Columbus, OH
Distribution: FreeBSD, preferably; Debian when I want to play Quake3.
Posts: 9

Rep: Reputation: 0
No, there's no syscall to do a killall.

Your best bet is to run through /proc/<digits> and check the first line of the "status" pseudo-file for the name. If it matches, kill that process.

Jeremy
 
Old 08-01-2003, 11:34 PM   #4
shishir
Member
 
Registered: Jul 2003
Location: bangalore . india
Distribution: openSUSE 10.3
Posts: 251

Rep: Reputation: 33
you have to be root to be able to execute the killall command...

you could use pkill <process name>..and if you are the owner of the process, you will be able to kill it....

u may use system() to do this......

hope this helped...if you really want to do this the hard way...what jemfinch says is good enough to satisfy your thirst to write C code
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
killall...but one? dibblethewrecke Programming 1 05-19-2005 11:31 AM
source code for libc function dvm Programming 1 12-27-2004 06:04 PM
source code for read() function ? Mike Davies Linux - Software 1 11-03-2004 02:10 PM
error function in c code shams Programming 3 08-06-2004 04:00 AM
What is correct code for "Include File Function" on .asp pages gregoryfrancis Linux - General 1 02-11-2003 10:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:25 PM.

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