LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-24-2004, 03:08 AM   #1
vibhory2j
Member
 
Registered: Apr 2004
Location: India
Posts: 42

Rep: Reputation: 15
fork()


hi,
i am new to linux. i just to want to know that if a command like fork() exists in Linux and if yes please tell me the use of it.

Thanks...

cheers
 
Old 05-24-2004, 05:11 AM   #2
bahramH
Member
 
Registered: Apr 2004
Location: France
Distribution: Mandrake
Posts: 67

Rep: Reputation: 15
fork ? Of course

Yes, of course fork exists in linux/C, and is similar to what it does in UNIX.

All these linux/unixes are multiprocesses operating systems, which means that at any given time, you have multiple process running in parallel (windows does the same since I guess
windows 98). ( ps -ef gives you all the running processes)

You have the ability, inside one process, to launch a new one. Each living process has a unique ID number (called PID) and a number referring to its parent ID (called PPID), i.e. the process which launched this one.

when you use the fork() command, you duplicate your original process. The processes are similar to each other, exept the PID and PPID. (fork return the pid of the child process)

Now, by cheking inside the two processes their own pid, you can induce each of them to perform a different task. You have many way to synchronize them. Look at the man pages for

fork, waitpid, ptrace,clone, exec, ...

I think the same concept in windows is called multithreading.
 
  


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
more on fork() feetyouwell Programming 6 09-17-2004 12:18 PM
fork beginner_84 Programming 2 08-20-2004 05:53 AM
Fork again Avatar33 Programming 13 08-22-2003 02:41 PM
fork() lowlifeish Programming 3 11-04-2002 11:50 AM
Fork Ztyx Linux - General 1 08-31-2002 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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