diff options
Diffstat (limited to 'src/user')
-rw-r--r-- | src/user/app/shell/shell.c | 3 | ||||
-rw-r--r-- | src/user/lib/syscall.c | 8 | ||||
-rw-r--r-- | src/user/lib/unistd.c | 4 |
3 files changed, 13 insertions, 2 deletions
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c index becc8d8..8e13029 100644 --- a/src/user/app/shell/shell.c +++ b/src/user/app/shell/shell.c @@ -80,6 +80,9 @@ void run_args(int argc, char **argv, struct redir *redir) { return; } else if (!strcmp(argv[0], "exit")) { exit(0); + } else if (!strcmp(argv[0], "getpid")) { + printf("my\t%d\nparent\t%d\n", getpid(), getppid()); + return; } if (fork()) { diff --git a/src/user/lib/syscall.c b/src/user/lib/syscall.c index f7eaddb..3e8473c 100644 --- a/src/user/lib/syscall.c +++ b/src/user/lib/syscall.c @@ -82,6 +82,14 @@ void _sys_intr_set(void __user *ip) { return (void)_syscall(_SYS_INTR_SET, (long)ip, 0, 0, 0, 0); } +uint32_t _sys_getpid(void) { + return (uint32_t)_syscall(_SYS_GETPID, 0, 0, 0, 0, 0); +} + +uint32_t _sys_getppid(void) { + return (uint32_t)_syscall(_SYS_GETPPID, 0, 0, 0, 0, 0); +} + long _sys_execbuf(void __user *buf, size_t len) { return _syscall(_SYS_EXECBUF, (long)buf, (long)len, 0, 0, 0); } diff --git a/src/user/lib/unistd.c b/src/user/lib/unistd.c index 28164e6..d6f24f8 100644 --- a/src/user/lib/unistd.c +++ b/src/user/lib/unistd.c @@ -185,11 +185,11 @@ pid_t getpgrp(void) { } pid_t getpid(void) { - __libc_panic("unimplemented"); + return _sys_getpid(); } pid_t getppid(void) { - __libc_panic("unimplemented"); + return _sys_getppid(); } int getgroups(int size, gid_t list[]) { |