add test case for the system call "getpid"
This commit is contained in:
parent
21e113c53a
commit
e6816bb0bd
1 changed files with 5 additions and 3 deletions
|
@ -28,7 +28,7 @@
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
int status = 0;
|
||||
pid_t pid;
|
||||
pid_t pid, mypid = getpid();
|
||||
|
||||
printf("Create child process...\n");
|
||||
|
||||
|
@ -37,12 +37,14 @@ int main(int argc, char** argv)
|
|||
char* newargs[] = {"/bin/hello", "one", "two", "three", NULL};
|
||||
char* newenv[] = {"USER=root", "PATH=/bin:/sbin:/usr/bin", "PWD=/", "TEMP=/tmp", NULL};
|
||||
|
||||
printf("Hello from child process!\n");
|
||||
mypid = getpid();
|
||||
printf("Hello from child process! mypid = %u\n", mypid);
|
||||
execve("/bin/hello", newargs, newenv);
|
||||
|
||||
return errno;
|
||||
} else {
|
||||
printf("Hello from parent process! pid = %u\n", pid);
|
||||
mypid = getpid();
|
||||
printf("Hello from parent process! pid = %u, mypid = %u\n", pid, mypid);
|
||||
wait(&status);
|
||||
printf("Child terminated with status %d\n", status);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue