fork/join

This is a discussion on fork/join within the C Programming forums, part of the General Programming Boards category; i'm trying to use fork() join() and wait() but my compiler says "fork underclaired (firts use this function)" what is ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    9

    fork/join

    i'm trying to use fork() join() and wait() but my compiler says "fork underclaired (firts use this function)"
    what is wrong?
    and which headers files do i need to fork processes ??
    thanx and sorry for the stupid question

  2. #2
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    993
    Presumably you're on a unix system, so you can just check the man pages, possibly with sections, as in "man 2 wait" or "man 3 wait", depending on how your system is set up.

    Although since there is no standard join() function which I'm aware of (certainly not one that works in conjunction with fork()), you might be on another system, in which case you'd want to consult its documentation; or at least mention what OS it is.

    If, for some reason, you haven't got any man pages, just do a search for man pages; there are loads of them online, and if they're from a mainstream unix-like OS, the general description will probably be good enough for you.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    The headers you probably need are:
    Code:
    #include <sys/types.h>
    #include <unistd.h>

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    9
    thanx guys
    i'm using winXP and dev++ compiler
    is there any way to declare these function in a header file?
    or can i find on the web the header files i need??
    thanx again

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Not sure what you are trying to do, but fork() is a unix/linux system call. There is, as far as I know, no "join" system call. There is a wait() function that relates to fork().

    Now, if you are doing this in Windows, you won't find a fork() call.

    Also, you need to include the right header file, which is unistd.h in most OS's.

    Edit: To slow...
    You can use cygwin, or start thinking of a different solution.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    fork() is a *nix function. It exists in OSs such as Linux, FreeBSD, etc... basically everything except Windows, which has no real equivalent to fork().

    Tell us what you're trying to do - there's probably a better solution.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  7. #7
    Registered User
    Join Date
    Jun 2009
    Posts
    9
    i study operating systems for my university and i found some codes with fork() and wait() and i tryed to execute them on my winXP pc. But i have these problems. Sorry but i didn't knew that i should run on UNIX like systems. From your posts i see that i can't do it on winXP

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by modulo_crt View Post
    i study operating systems for my university and i found some codes with fork() and wait() and i tryed to execute them on my winXP pc. But i have these problems. Sorry but i didn't knew that i should run on UNIX like systems. From your posts i see that i can't do it on winXP
    Try
    Cygwin Information and Installation

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Install cygwin, and run them that way. Cygwin Information and Installation


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Two votes for Cygwin... Must be a winner.

    Just beware that the fork isn't a REAL fork - it's a simulated fork. It's pretty close to the real thing, but since Windows can not do fork, Cygwin works out something that is pretty close. It won't work in ALL situations where fork in a Unix system works. But you probably have to do some pretty complicated/unusual things to discover those bits.

    --
    Mats
    Last edited by matsp; 06-08-2009 at 06:29 PM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Jun 2009
    Posts
    9
    thanx guys for your attension

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21