Question about Unix programming

Sharky Forums


Results 1 to 3 of 3

Thread: Question about Unix programming

  1. #1
    Catfish
    Join Date
    Jan 2002
    Posts
    134

    Question Question about Unix programming

    hey guys got some question about Unix programming. what is fork()? what does it use for? what is wait()? what is it used for? what is pipe()? what does it use for? can u give me some information coz, i have to write a simuation program which simulate a call center which a customer call in we direct the call to the call center
    Thank You

  2. #2
    Tiger Shark
    Join Date
    Feb 2001
    Location
    Satan Country
    Posts
    564
    fork() creates a new process, and pipe is used for interprocess communication.

    So you can have code like

    if(fork())
    {
    //do child process stuff here

    return;
    }

    //do parent process stuff here

    to spawn processes.

    for pipe it is a little trickier and I can't remember how to do it exactly without looking it up, but it allows processes to communicate with each other or signal each other - usually to let them know when one finishes or to signal to the other one it has data waiting etc. I kind of like shared memory better, but people seem to have massive problems with it.

    I do not think that wait() actually works like you would expect.

    Last time I was doing unix programming, there was no wait or sleep functions that actually did what you expect, though this may have changed since then.
    I'm half Scottish and half French.

    I surrender to alcohol.

  3. #3
    Hammerhead Shark e_dawg's Avatar
    Join Date
    Jan 2001
    Location
    Earth, Western Hemisphere, North America, US, UT, SLC
    Posts
    2,628
    I know what they do in Java, but it's been a while since I have done process forking in C++... I'd imagine wait() should work the same way, but who knows.

    bryce777 basically explained it. I'm guessing you need handler processes that are forked off the main process to handle incoming connections, such as that in a socket handler class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •