Overclock.net - An Overclocking Community

Overclock.net - An Overclocking Community (https://www.overclock.net/forum/)
-   Coding and Programming (https://www.overclock.net/forum/142-coding-programming/)
-   -   fork script in c++ (https://www.overclock.net/forum/142-coding-programming/62546-fork-script-c.html)

Mental 12-24-2005 12:05 AM

does anybody have an example of a fork script written in c++?

zone 12-24-2005 04:09 AM

Does this or this or this help or are they too trivial ?

Mental 12-24-2005 09:26 AM

for some reason whenever i try to compile code i find on the internet it never works and i get atleast 10 error messages. that is how it should be able to be done right? im using Dev-C++ anybody got any ideas

amped 12-24-2005 09:33 AM

It could be that you don't have the libraries that the program includes. Make sure you have them all before you try to compile it.

Mental 12-24-2005 09:36 AM

thats sounds like it could be it cause im putting in normal functions and its not reccognizing them for some reason. do you know how i would get the libraries for Dev C++ installed? thanks

Mental 12-24-2005 06:23 PM

when i try to compile this script

Code:
#include <sys/types.h>
#include <unistd.h>

pid_t fork(void);

pid_t pid;

switch (pid = fork())
{
case -1:
    /* Here pid is -1, the fork failed */
    /* Some possible reasons are that you're */
    /* out of process slots or virtual memory */
    perror("The fork failed!");
    break;

case 0:
    /* pid of zero is the child */
    /* Here we're the child...what should we do? */
    /* ... */
    /* but after doing it, we should do something like: */
    _exit(0);

default:
    /* pid greater than zero is parent getting the child's pid */
    printf("Child's pid is %d\
",pid);
}
i get an error in line 8 about the switch command. any ideas?


All times are GMT -7. The time now is 01:06 PM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
vBulletin Security provided by vBSecurity (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.

vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.