General Fork()/Exec()/System() Call Question

General Fork()/Exec()/System() Call Question

Post by Jonathan S. Willa » Fri, 10 Sep 1993 05:43:40



W. Richard Stevens indicates in "Advanced Programming in the UNIX Environment"
that fork and exec use COW (copy on write) to allow the parent's and child's
memory to be shared so as to avoid a complete memory copy (page 189).

During my investigation I have found that fork/exec still require at least
the same amount of available virtual memory as the parent process.

I have also found that system() does not seem to require this.

1) What are the differences between the fork/exec method and the system
method?
   Is it just that system uses vfork?  Are there other subtle
differences?

2) How much memory does system() require? (Not including mem for the *cmd).

3) What else should I know about these calls?

4) What are the platform/OS version differences that I should know?

5) Where can I find a good resource about this?

 
 
 

General Fork()/Exec()/System() Call Question

Post by Mark Ensto » Fri, 10 Sep 1993 08:03:10



Quote:>W. Richard Stevens indicates in "Advanced Programming in the UNIX Environment"
>that fork and exec use COW (copy on write) to allow the parent's and child's
>memory to be shared so as to avoid a complete memory copy (page 189).

>During my investigation I have found that fork/exec still require at least
>the same amount of available virtual memory as the parent process.

>I have also found that system() does not seem to require this.

>1) What are the differences between the fork/exec method and the system
>method?
>   Is it just that system uses vfork?  Are there other subtle
>differences?

>2) How much memory does system() require? (Not including mem for the *cmd).

>3) What else should I know about these calls?

What about where the childs stdout/stderr is to go? And from whence it
takes stdin?

What about not wanting to wait fo the child process to complete?

System calls /[s]bin/sh to parse the const char *string parameter you
give to system(2). With fork/exec there is no intermediate sh[ell]
involved.

Quote:

>4) What are the platform/OS version differences that I should know?

>5) Where can I find a good resource about this?

man 2 exec
man 2 fork
man 3s system
man sh

 
 
 

1. exec & fork in a system call

Hi,

  I am trying to use execve() and fork() in a system call.
 I am trying to call sys_fork and sys_exec in my system call.
 But both these expect a pointer struct to be passed to them.

  struct pt_regs * regs

  that is defined in ptrace.h. I dont know how to fill the structure
 with the values. All the fields  in this struct are register fields.

  I would appreciate if someone could direct me in a proper direction.

  BTW, I am trying to fork and exec in a system call so that I can
 execute a binary(vi/emacs) by calling it from the system call.

 Thanks for the help.

--
Marx Rajangam
Fisher 227, CS Dept,
Michigan Tech. Univ.

2. What am I missing?

3. Fork and Exec system calls

4. NFS & Lockd/Statd

5. exec & fork in a system call

6. Automatic SLIP connection with telnet/ftp

7. Input across fork() and exec() calls

8. Legend "Sparc" machines

9. Efficiency: fork() w/ shared libraries vs. fork()/exec()

10. rsh in a system() or fork/exec on AIX

11. system(command) = fork + exec(command)? kill parent, children?

12. system() vs. fork/exec/waitpid

13. fork/exec question