source: trunk/libs/newlib/src/newlib/libc/sys/linux/process.c

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.2 KB
Line 
1/* libc/sys/linux/process.c - Process-related system calls */
2
3/* Written 2000 by Werner Almesberger */
4
5
6#include <sys/unistd.h>
7#include <sys/wait.h>
8#include <machine/syscall.h>
9
10
11#define __NR__exit __NR_exit
12#define __NR__execve __NR_execve
13
14_syscall0(int,getpid)
15_syscall0(pid_t,getppid)
16
17weak_alias(__libc_getpid,__getpid);
18
19#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 3
20_syscall3(int,_execve,const char *,file,char * const *,argv,char * const *,envp)
21_syscall0(int,fork)
22#endif /* _ELIX_LEVEL >= 3 */
23
24#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 4
25_syscall0(pid_t,getpgrp)
26_syscall2(int,setpgid,pid_t,pid,pid_t,pgid)
27_syscall0(pid_t,setsid)
28
29/* Here we implement vfork in terms of fork, since
30 * Linux's vfork system call is not reliable.
31 */
32pid_t vfork(void)
33{
34  pid_t pid;
35
36  pid = fork();
37 
38  if(!pid)
39    {
40      /* In child. */
41      return 0;
42    }
43  else
44    {
45      /* In parent.  Wait for child to finish. */
46      if (waitpid (pid, NULL, 0) < 0)
47        return pid;
48    }
49}
50#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 4 */
51
52
53/* Although _exit is listed as level 3, we use it from level 1 interfaces */
54/* FIXME: get rid of noreturn warning */
55
56#define return for (;;)
57_syscall1(void,_exit,int,exitcode)
58#undef return
Note: See TracBrowser for help on using the repository browser.