generated from CSCE313-SP23-Kebo/quiz-2-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
printvars.c
34 lines (31 loc) · 867 Bytes
/
printvars.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
char *custom_env[] = {"USER=Pikachu", "PATH=/tmp", NULL};
int main(void)
{
// TODO
pid_t pid1=fork();
if(pid1==0)
{
printf("Running child process PID: %d\n",getpid());
char *arg[]={"echoall","Bandicoot","Pacman",NULL};
execle("/home/zwubn/-CSCE313-SP23-Kebo-quiz-2-2./echoall",arg[0],arg[1],arg[2],NULL,custom_env);
}
else{
printf("Running parent process PID: %d\n",getpid());
printf("\n");
wait(NULL);
pid_t pid2=fork();
if(pid2==0)
{
printf("Running child process PID: %d\n",getpid());
execlp("/home/zwubn/-CSCE313-SP23-Kebo-quiz-2-2./echoall","Spyro",NULL);
}
wait(NULL);
}
exit(0);
}