LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 06-15-2003, 01:24 PM   #1
Linh
Member
 
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
C funtion to obtain a process ID


1) What is the C function to obtain a process id of say smbd and nmbd or any other process using the name of that process?

2) What is the C function to stop a process ID?

I do not want to use system("killall nmbd") since this will execute a bash command from within a C program. I wanted to use all C function.
 
Old 06-15-2003, 02:19 PM   #2
Flibble
Member
 
Registered: Mar 2002
Distribution: Redhat 9.0, Debian, Knoppix, YellowDog
Posts: 142

Rep: Reputation: 15
Dog isn't my best friend, man is. ;>

man 5 proc
man 2 kill

Flibble
 
Old 06-15-2003, 04:28 PM   #3
Linh
Member
 
Registered: Apr 2003
Posts: 178

Original Poster
Rep: Reputation: 30
C program

man 5 proc and man 2 kill

You mean a man page on proc and kill ? manual page is bash command not a built in C function, am I correct ? What I was asking was the built in C function.
 
Old 06-15-2003, 05:32 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Re: C program

Quote:
Originally posted by Linh
man 5 proc and man 2 kill

manual page is bash command not a built in C function, am I correct ? What I was asking was the built in C function.
Are you sure you didn't forget to type the '2' in between 'man' and 'kill'.
If you did type the '2', but you didn't get a man page, you probably have not installed the development man pages package. In Debian this package is called 'manpages-dev'.
 
Old 06-18-2003, 12:35 PM   #5
LandRoverMan
LQ Newbie
 
Registered: Jun 2003
Location: North Wales, United Kingdom
Posts: 25

Rep: Reputation: 15
I thnk Flibble was gently teasing - he/she meant read those manual pages...
 
Old 06-18-2003, 02:37 PM   #6
Flibble
Member
 
Registered: Mar 2002
Distribution: Redhat 9.0, Debian, Knoppix, YellowDog
Posts: 142

Rep: Reputation: 15
You got it. ;>

Flibble

man 2 kill

KILL(2) Linux Programmer’s Manual KILL(2)

NAME
kill - send signal to a process

SYNOPSIS
#include <sys/types.h>
#include <signal.h>

int kill(pid_t pid, int sig);


man 5 proc

PROC(5) Linux Programmer’s Manual PROC(5)

NAME
proc - process information pseudo-filesystem

DESCRIPTION
/proc is a pseudo-filesystem which is used as an interface to kernel
data structures rather than reading and interpreting /dev/kmem. Most
of it is read-only, but some files allow kernel variables to be
changed.

The following outline gives a quick tour through the /proc hierarchy.
 
  


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
Obtain ip address and check for running process via Bash Script? xconspirisist Programming 10 09-12-2008 01:18 PM
error coding a funtion in c shams Programming 2 07-27-2004 09:47 PM
How to allocate memory for a null pointer passed to a funtion? (C) MadCactus Programming 3 01-30-2004 07:54 AM
error: use funtion socket c in Qt Designer? nhan Programming 0 01-07-2004 02:30 AM
Numbered Keypad doesn't funtion. l0f33t Linux - Hardware 1 05-25-2003 11:16 AM

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

All times are GMT -5. The time now is 04:40 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