Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fork help

Name: Anonymous 2011-11-03 1:58

Programming help..
  A
/ | \
B C D
 / \ \
 E F  G
For our assignment we are supposed to (in writing) say how we can perform the creation of said processes using 6, 5, 4, and 3 fork calls. I can understand 6 calls easy enough, but I am a little confused on how to accomplish it with less.

My basic thought is to do the initial fork, then if the pid is 0 do some condition to fork again.. but I am a little confused. Any help would be appreciated. I don't need the code, and I don't need all of the solved, just a little push in the right direction.

Name: Anonymous 2011-11-03 5:17


NAME
     spork -- generate a random process

SYNOPSIS
     #include <cutlery.h>

     void
     spork(void);


DESCRIPTION
     spork() generates a new, random process by blending
     characteristics from the calling process and the process
     which most recently invoked spoon() in the current
     process group. These characteristics may include any or
     all of the following:

     * Current working directory
     * Open file descriptors, directory streams, and
       memory-mapped files (open(2), opendir(3), mmap(2))
     * Environment variables
     * Memory and record locks (mlock(2), flock(2))
     * Resource limits

     Pending asynchronous I/O operations, semaphores, and
     timers are not inherited by the spork()ed process.
     Threading behaves similarly to fork(), i.e. handlers
     defined with pthread_atfork(3) in both the fork() and
     spoon() processes are invoked when calling spork().


RETURN VALUES
     spork() returns 0 on success, and nonzero on error.


ERRORS
     spork() will fail and subsequent spork() will fail if:

     [ENOMEM]     Not enough memoory is available to create
                  the task structure for the new process.


SEE ALSO
     execve(2), fork(2), spoon(2)


HISTORY
     A spork() function call appeared in Anonix Prerelease -7.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List