LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 05: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, 05:45 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
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 Aquarius_Girl; 09-24-2010 at 06:13 AM. Reason: added popen ()
 
1 members found this post helpful.
Old 09-24-2010, 06:56 AM   #3
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: RHEL/Ubuntu/Debian/Fedora/Centos/K3OS
Posts: 1,159
Blog Entries: 4

Rep: Reputation: 149Reputation: 149
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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