Changeset View
Changeset View
Standalone View
Standalone View
lldb/test/API/commands/expression/fork/main.cpp
- This file was added.
#include <sys/types.h> | |||||
#include <unistd.h> | |||||
pid_t do_fork(char *const argv[], char *const envp[]) { | |||||
pid_t pid = fork(); | |||||
if (pid == 0) | |||||
execve(argv[0], argv, envp); | |||||
return pid; | |||||
} | |||||
pid_t do_vfork(char *const argv[], char *const envp[]) { | |||||
pid_t pid = vfork(); | |||||
if (pid == 0) | |||||
execve(argv[0], argv, envp); | |||||
return pid; | |||||
} | |||||
int main(int argc, char *const argv[], char *const envp[]) { | |||||
// Stop here to evaluate expressions | |||||
// Optionally call do_fork() when argc is 4 to make sure do_fork() doesn't get | |||||
// dead stripped | |||||
if (argc == 4) | |||||
do_fork(argv, envp); | |||||
// Optionally call do_vfork() when argc is 5 to make sure do_fork() doesn't | |||||
// get dead stripped | |||||
if (argc == 5) | |||||
do_vfork(argv, envp); | |||||
return 0; | |||||
} |