u32_t p_privl;
pid_t p_id;
pid_t p_pid;
+ uid_t p_uid;
+ gid_t p_gid;
struct {
struct cxmsg *msg;
{
int ret_val;
process_t *proc;
- pid_t ppid;
ret_val = -ENOMEM;
proc = NULL;
- ppid = 1;
/* was a specific pid requested? */
if(pid != PID_ANY) {
/* inherit the ppl from the current task, in the case of fork and vfork */
ctask = task_get_current();
ppl = ctask->t_privl;
- ppid = ctask->t_pid;
}
proc = kmalloc(sizeof(*proc));
if(proc) {
+ process_t *cproc;
void *pdbr;
void *kstack;
void *ustack;
goto cleanup;
}
+ cproc = process_get_current();
+
+ if(cproc) {
+ /* inherit uid and gid from the current process */
+ proc->p_uid = cproc->p_uid;
+ proc->p_gid = cproc->p_gid;
+
+ /* set the ppid */
+ proc->p_pid = cproc->p_id;
+
+ /* also inherit the scheduling settings */
+ proc->p_tasks->t_tslice = cproc->p_tasks->t_tslice;
+ proc->p_tasks->t_rslice = proc->p_tasks->t_tslice;
+ } else {
+ /*
+ * This only happens when process_create() is called before the
+ * scheduler is invoked for the first time.
+ */
+ proc->p_uid = 0;
+ proc->p_gid = 0;
+ proc->p_pid = 0;
+
+ proc->p_tasks->t_tslice = 50;
+ proc->p_tasks->t_rslice = 50;
+ }
+
/* set the default signal handlers */
memcpy(proc->p_sighandler, _sig_dfl, sizeof(proc->p_sighandler));
proc->p_privl = ppl;
- proc->p_pid = ppid;
if(pid == PID_ANY) {
/* no specific pid requested */
}
proc->p_tasks->t_kstack = kstack;
- proc->p_tasks->t_tslice = 50;
- proc->p_tasks->t_rslice = 50;
proc->p_tasks->t_proc = proc;
proc->p_tasks->t_pid = proc->p_id;