Thread: Help needed in creating a process

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    2

    Help needed in creating a process

    hi guys
    i need ur help in creating a process. my program is as follows

    program is to

    1) First print your name and student id;
    2) Accept and parse user's input, which may consist of multiple (for simplicity at most 2) shell commands separated by '&' (ampersand) character
    (for example ls -a & cat fork.c).
    3) Create a child process using system call fork;
    4) Execute the first command in the child process using system call exec; and
    5) Execute the second command, if exists, in the parent process using system call exec.

    Student ID is like any other ID. User will input it.
    The fork() function is used to create a new process from an existing process.
    The new process is called the child process, and the existing process is called the parent. You can tell which is which by checking the return value from fork(). The parent gets the child's pid returned to him, but the child gets 0 returned to him.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Welcome, please post you attempt using code tags: [code][/code].
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Awesomefaceradcore bivhitscar's Avatar
    Join Date
    Apr 2006
    Location
    Melbourne, Australia
    Posts
    210
    So before we do your homework for you, do you want to at least show us your attempt at this project? =\

    Please read the forum guidelines about homework questions.
    it's ironic considerate rarity patron of love higher knowledge engulfs me...

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    2

    Here is my work:

    Quote Originally Posted by bivhitscar
    So before we do your homework for you, do you want to at least show us your attempt at this project? =\

    Please read the forum guidelines about homework questions.

    i have created the child and parent process. now i'm getting confused in inputting the second command if exists in the parent process using system call exec. also how to accept multiple commands separated by '&'

    my work is as follows:
    << untagged code deleted by moderator - if you can't follow simple instructions, forget about programming>>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. init adopts zombie process?
    By password636 in forum Linux Programming
    Replies: 4
    Last Post: 07-01-2009, 10:05 AM
  2. Killing A Process
    By tommyb05 in forum C Programming
    Replies: 8
    Last Post: 06-01-2009, 06:41 AM
  3. Round Robin Scheduling using c.
    By eclipt in forum C Programming
    Replies: 8
    Last Post: 12-28-2005, 04:58 PM
  4. Urgent help needed in Socket Programming
    By lisa23 in forum C Programming
    Replies: 2
    Last Post: 09-15-2005, 11:18 PM
  5. redirection program help needed??
    By Unregistered in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2002, 05:50 AM