LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-24-2010, 06:30 AM   #1
mailkamlesh
LQ Newbie
 
Registered: Apr 2010
Posts: 10

Rep: Reputation: 0
Create and Call a Process


Hi All

I had an interview , where the interviewer asked me the question
"How to create and call a process in unix"


I answered that we can use the command
FORK()/ CLONE() to create a process.

But I didnt have the answer for the second question, how to call a process.

Can someone help me with the second question ?

Thanks
 
Old 09-24-2010, 06:45 AM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Quote:
Originally Posted by mailkamlesh View Post
how to call a process.
Process is just a program in execution.

e.g. The set of lines written in the ls file is a program and when we type ls on the prompt, it gets called and thus the ls becomes a process which we called !!

and also you can use special system calls to call a program e.g. system (), execvp () and popen () etc.

IMHO

Last edited by TheIndependentAquarius; 09-24-2010 at 07:13 AM. Reason: added popen ()
 
1 members found this post helpful.
Old 09-24-2010, 07:56 AM   #3
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
System call is the services provided by Linux kernel. In C programming, it often uses functions defined in libc
which provides a wrapper for many system calls.

It is also possible to invoke syscall() function directly. Each system call has a function number defined in
<syscall.h> or <unistd.h>. Internally, system call is invokded by software interrupt 0x80 to transfer control to
the kernel. System call table is defined in Linux kernel source file “arch/i386/kernel/entry.S ”

System Call Example
#include <syscall.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
int main(void) {
long ID1, ID2;
/*-----------------------------*/
/* direct system call */
/* SYS_getpid (func no. is 20) */
/*-----------------------------*/
ID1 = syscall(SYS_getpid);
printf ("syscall(SYS_getpid)=%ld\n", ID1);
/*-----------------------------*/
/* "libc" wrapped system call */
/* SYS_getpid (Func No. is 20) */
/*-----------------------------*/
ID2 = getpid();
printf ("getpid()=%ld\n", ID2);
return(0);
}
 
  


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
How to a detect process is running in system call or not? nisarg Linux - Kernel 3 03-18-2009 07:19 PM
Create a new system call jianelisj Linux - Newbie 3 03-21-2008 05:42 PM
Call function in another process Gabbiadini Programming 1 10-27-2007 09:17 AM
tracing 'create' system call called by any process to kernel viv_nan Linux - General 3 03-07-2007 12:09 PM
When does process swap happen in a system call? oldfogie Programming 3 05-03-2005 08:35 PM


All times are GMT -5. The time now is 10:19 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration