Difference between Fork and Vfork


 
Thread Tools Search this Thread
Operating Systems Linux Difference between Fork and Vfork
# 1  
Old 04-17-2012
Difference between Fork and Vfork

Hello Forum members,



What is the prime difference between fork and Vfork and when to prefer in our aapications this Vfork.


Thanks
Siva Ranganath

Last edited by workforsiva; 04-17-2012 at 01:23 AM.. Reason: For thanks
# 2  
Old 04-17-2012
fork() copies everything from the parent process to the child, vfork() is a special instance of clone(), and does not copy all process information. vfork is meant solely as a low-impact way to call exec() to create a new process. clone() was originally meant for creating threads because early Linux threads were really separate child processes with special tweaks, not LWP's still associated with the parent.

You cannot do anything in the child process after a vfork() call except to call exit() or to call one of the exec() family. fork() lets you continue running the child, if you want.
# 3  
Old 04-18-2012
Thanks Jim mcnamara and Unix forum.

Thanks for ur quick reply with good explanination. as i am facing interviews on linux . iam looking more help from Forum memebers.
Thanks once agin Jim mcnamara sir. iam looking same help for further queries.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Programming

Fork!

I understand that fork create a child but I need very simple example that make child useful.... I mean how will make the program faster anyone explain with code plz using C plz (2 Replies)
Discussion started by: fwrlfo
2 Replies

3. Programming

what is the main difference between difference between using nonatomic lseek and O_APPEND

I think both write at the end of the file ...... but is there a sharp difference between those 2 instruction ..... thank you this is my 3rd question today forgive me :D (1 Reply)
Discussion started by: fwrlfo
1 Replies

4. Programming

Vfork error

I'm trying to study about vfork. when i used vfork, it shows the output as follows. #include <sys/types.h> #include <stdio.h> #include <sys/wait.h> void main() { int pid; int status; pid = vfork(); if(pid == 0) { printf("\nChild... (2 Replies)
Discussion started by: aarathy
2 Replies

5. UNIX for Dummies Questions & Answers

fork()

I'm trying to run a simple test on how to use fork(), i'm able to execute the child process first then the parent, but how can I execute parent then child..? Thanks! (1 Reply)
Discussion started by: l flipboi l
1 Replies

6. UNIX for Dummies Questions & Answers

oh fork() and vfork() someone explain the difference?

Can somebody explain to me the differences between fork() and vfork() system calls using C programs which I can implement in the UNIX environement? (1 Reply)
Discussion started by: lvkchaitanya
1 Replies

7. Programming

fork() help

Hi everybody, I wanna write a code to understand how fork works. my target -------------- -Parent creates a file(called temp) and writes into this file "1".Then it closes the file. -Then parent creates a child and wait until execution of this child ends. -Then child opens the same... (3 Replies)
Discussion started by: alexicopax
3 Replies

8. Programming

Fork or what?

Hello all. I'm developing a filetransfer application, which is supposed to work sort of like dcc, with multiple transfers etc. Now i wonder what the best way to manage the transfers is. Should i fork() for each new transfer, hogging loads of memory or use pthreads? Maybe I can use select to see... (0 Replies)
Discussion started by: crippe
0 Replies

9. Programming

fork()

#include <stdio.h> #include <string.h> #include <sys/types.h> #define MAX_COUNT 200 #define BUF_SIZE 100 void main(void) { pid_t pid; int i; char buf; fork(); pid = getpid(); for (i = 1; i <= MAX_COUNT; i++) { sprintf(buf,... (2 Replies)
Discussion started by: MKSRaja
2 Replies

10. Programming

fork() fd

I run this code, actually I want to both processes print the message from "data". But only one does. What happens? Anyone can help? #include <stdio.h> main(){ int fd, pid; char x; fd = open("data",0); /* open file "data" */ pid = fork(); if(pid != 0){ wait(0); ... (2 Replies)
Discussion started by: Herman
2 Replies
Login or Register to Ask a Question