This commit is contained in:
parent
54f2d35416
commit
40f01c825d
@ -37,12 +37,12 @@ int main()
|
|||||||
|
|
||||||
fprintf(stderr, "init is running as PID %d\n", getpid());
|
fprintf(stderr, "init is running as PID %d\n", getpid());
|
||||||
|
|
||||||
long ret = syscall(SYS_fork);
|
pid_t ret = fork();
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
char* argv[] = { "/bin/hello", "--help", NULL };
|
char* argv[] = { "/bin/hello", "--help", NULL };
|
||||||
execv("/bin/hello", argv);
|
execv("/bin/hello", argv);
|
||||||
}
|
}
|
||||||
else { printf("my child is PID %ld!\n", ret); }
|
else { printf("my child is PID %d!\n", ret); }
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pid_t fork();
|
/* Create a new process that is a clone of the current one. */
|
||||||
|
pid_t fork(void);
|
||||||
|
|
||||||
/* Return the current process' process ID. */
|
/* Return the current process' process ID. */
|
||||||
pid_t getpid(void);
|
pid_t getpid(void);
|
||||||
|
@ -8,6 +8,12 @@ extern "C" long arch_invoke_syscall(long, uintptr_t, uintptr_t, uintptr_t, uintp
|
|||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
pid_t fork(void)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_fork);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
pid_t getpid(void)
|
pid_t getpid(void)
|
||||||
{
|
{
|
||||||
return (pid_t)syscall(SYS_getpid);
|
return (pid_t)syscall(SYS_getpid);
|
||||||
|
Loading…
Reference in New Issue
Block a user