+ exec* functions
[meinos.git] / apps / include / proc.h
blob6b2d2173ee71a646e9ec4ea58f66fbf5806b49c4
1 /*
2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _PROC_H_
20 #define _PROC_H_
22 #include <sys/types.h>
23 #include <syscall.h>
24 #include <signal.h>
25 #include <unistd.h>
27 #define getchild(i) getchildbypid(getpid(),i)
29 static __inline__ pid_t proc_create(char *name,uid_t uid,gid_t gid,pid_t parent) {
30 return syscall_call(SYSCALL_PROC_CREATE,4,name,uid,gid,parent);
33 static __inline__ int proc_destroy(pid_t pid) {
34 return syscall_call(SYSCALL_PROC_DESTROY,1,pid);
37 static __inline__ int proc_getvar(pid_t pid,int var) {
38 return syscall_call(SYSCALL_PROC_GETVAR,1,pid);
41 static __inline__ void proc_setvar(pid_t pid,int var) {
42 syscall_call(SYSCALL_PROC_SETVAR,2,pid,var);
45 static __inline__ void proc_setname(pid_t pid,const char *name) {
46 syscall_call(SYSCALL_PROC_SETNAME,2,pid,name);
49 static __inline__ void *proc_memmap(pid_t pid,void *virt,void *phys,int writable,int swappable,int cow) {
50 return (void*)syscall_call(SYSCALL_PROC_MEMMAP,6,pid,virt,phys,writable,swappable,cow);
53 static __inline__ void *proc_memalloc(pid_t pid,void *virt,int writable,int swappable) {
54 return (void*)syscall_call(SYSCALL_PROC_MEMALLOC,4,pid,virt,writable,swappable);
57 static __inline__ int proc_memunmap(pid_t pid,void *virt) {
58 return syscall_call(SYSCALL_PROC_MEMUNMAP,2,pid,virt);
61 static __inline__ int proc_memfree(pid_t pid,void *virt) {
62 return syscall_call(SYSCALL_PROC_MEMFREE,2,pid,virt);
65 static __inline__ void *proc_memget(pid_t pid,void *virt,int *exists,int *writable,int *swappable,int *cow) {
66 return (void*)syscall_call(SYSCALL_PROC_MEMGET,6,pid,virt,exists,writable,swappable,cow);
69 static __inline__ int proc_system(pid_t pid,int system) {
70 return syscall_call(SYSCALL_PROC_SYSTEM,2,pid,system);
73 static __inline__ int proc_jump(pid_t pid,void *dest) {
74 return syscall_call(SYSCALL_PROC_JUMP,2,pid,dest);
77 static __inline__ int proc_createstack(pid_t pid) {
78 return syscall_call(SYSCALL_PROC_CREATESTACK,1,pid);
81 static __inline__ void proc_run(pid_t pid) {
82 kill(pid,SIGCONT);
85 static __inline__ void proc_stop(pid_t pid) {
86 kill(pid,SIGSTOP);
89 static __inline__ pid_t getpidbyname(const char *name) {
90 return syscall_call(SYSCALL_PROC_GETPIDBYNAME,1,name);
93 static __inline__ uid_t getuidbypid(pid_t pid) {
94 return syscall_call(SYSCALL_PROC_GETUID,1,pid);
97 static __inline__ uid_t getgidbypid(pid_t pid) {
98 return syscall_call(SYSCALL_PROC_GETGID,1,pid);
101 static __inline__ pid_t getppidbypid(pid_t pid) {
102 return syscall_call(SYSCALL_PROC_GETPARENT,1,pid);
105 static __inline__ gid_t getpgidbypid(pid_t pid) {
106 return syscall_call(SYSCALL_PROC_GETGID,1,pid);
109 static __inline__ pid_t getchildbypid(pid_t pid,size_t i) {
110 return syscall_call(SYSCALL_PROC_GETCHILD,2,pid,i);
113 char *getname(pid_t pid);
114 void **proc_mempagelist(pid_t pid,size_t *_num_pages);
115 int proc_pack_procdata(char **argv,char **env,char *cwd,mode_t cmask);
116 int proc_unpack_procdata(int var,int *argc,char ***argv);
118 #endif