fork script in c++ - Overclock.net - An Overclocking Community

Forum Jump: 

fork script in c++

 
Thread Tools
post #1 of 6 (permalink) Old 12-24-2005, 12:05 AM - Thread Starter
New to Overclock.net
 
Join Date: Feb 2005
Posts: 1,555
Rep: 67 (Unique: 55)
does anybody have an example of a fork script written in c++?

Mental is offline  
Sponsored Links
Advertisement
 
post #2 of 6 (permalink) Old 12-24-2005, 04:09 AM
 
Join Date: Oct 2005
Posts: 1,077
Does this or this or this help or are they too trivial ?
zone is offline  
post #3 of 6 (permalink) Old 12-24-2005, 09:26 AM - Thread Starter
New to Overclock.net
 
Join Date: Feb 2005
Posts: 1,555
Rep: 67 (Unique: 55)
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

Mental is offline  
Sponsored Links
Advertisement
 
post #4 of 6 (permalink) Old 12-24-2005, 09:33 AM
New to Overclock.net
 
Join Date: Oct 2005
Posts: 1,674
Rep: 121 (Unique: 103)
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.

amped is offline  
post #5 of 6 (permalink) Old 12-24-2005, 09:36 AM - Thread Starter
New to Overclock.net
 
Join Date: Feb 2005
Posts: 1,555
Rep: 67 (Unique: 55)
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 is offline  
post #6 of 6 (permalink) Old 12-24-2005, 06:23 PM - Thread Starter
New to Overclock.net
 
Join Date: Feb 2005
Posts: 1,555
Rep: 67 (Unique: 55)
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?

Mental is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off