Created
June 9, 2018 00:58
-
-
Save tmlbl/d61ad03890867aec8fcabcfe59683e8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
typedef struct widget { | |
double value; | |
} widget; | |
void printval(int pid, double val) | |
{ | |
printf("pid: %d value: %f\n", pid, val); | |
} | |
void split(widget *w) | |
{ | |
int pid = fork(); | |
if (pid) { | |
w->value = 0.2; | |
printval(pid, w->value); | |
sleep(1); | |
} else { | |
sleep(1); | |
printval(pid, w->value); | |
} | |
} | |
int main() | |
{ | |
widget w; | |
split(&w); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment