generated from PlexSheep/baserepo
add fork and comment translate
This commit is contained in:
parent
37bbe98da4
commit
add1185efc
|
@ -8,3 +8,4 @@ include_directories(${PROJECT_SOURCE_DIR})
|
|||
add_executable( hello src/hello.c )
|
||||
add_executable( args src/args.c )
|
||||
add_executable( translate src/translate.c )
|
||||
add_executable( fork src/fork.c )
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
pid_t pid;
|
||||
if ((pid = fork()) < 0) {
|
||||
fprintf(stderr, "ERROR: Fork failed (%s)\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pid != 0) {
|
||||
printf("Parent process (%d) of child process (%d)\n", getpid(), pid);
|
||||
} else {
|
||||
printf("Child process (%d)\n", getpid());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
/*
|
||||
* Read from stdin. replace all occurences of arg 1 with arg2.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue