Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-16-2009, 12:50 AM   #1
Registered: May 2009
Posts: 44

Rep: Reputation: 15
Post how does shell invoke a process?

How does Shell invoke a process, when an application is executed?
If I do not run any command, is any IDLE thread running?
Old 06-16-2009, 01:43 AM   #2
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 34
'Shell' probably invokes a process by using a member of the exec() family of functions. Read the source code of 'Shell' for details. Also check out fork(), pipe().
Old 06-16-2009, 05:07 AM   #3
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Okay, you're asking a pretty complex question here, but I'll try an explain as best I can. Firstly, a process on Linux:

Processes are stored in the task list which is (get ready for it) a Circular Doubly Linked List. These elements are Process Descriptors and contain everything theprocess needs to run in a struct task_struct- you'll find this in the header file <linux/sched.h>.

Right; now we know that, we can look at processes- a process must have a parent, apart from init(ish), though that is different. The parent calls the fork() system call which duplicates the existing process, though obviously with different PID and PPID and certain resources, and then calls exec() which loads a new executable to the addess space.

fork() is implemented through the clone() system call which takes flags to specify which resources to share, to specify different flags, you'd use a different fork; such as vfrok() or _clone().

Everything you never wanted to know about process creation in the kernel, so to translate to this; the shell creates a new process, the kernel calls fork() to create a new instance of the shell process (Which in turn uses clone() and some other stuff, thats probably less important to you). exec() then loads the command its self into the address space.

There, that should confuse you enough to go do your homework yourself.


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
Shell script for reading a particular process contineously from process table vinaykori Linux - General 2 05-29-2009 06:52 AM
Shell Script : Kill a running process when another process starts ashmew2 Linux - General 3 08-20-2008 03:47 AM
how can I invoke "awk" from shell to do floating point math? Joseph Schiller Programming 8 01-12-2006 05:00 AM
Invoke kickstart installation from Linux shell jeff99chapman Red Hat 2 10-26-2005 11:14 AM
How to invoke FTP from Korn shell WindozBytes Programming 6 09-07-2002 08:53 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:46 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration