uintptr_t ustack_top;
struct llist_header siblings;
struct llist_header children;
+ struct llist_header grp_member;
struct proc_mm mm;
void* page_table;
time_t created;
sigset_t sig_pending;
sigset_t sig_mask;
void* sig_handler[_SIG_NUM];
+ pid_t pgid;
struct lx_timer* timer;
};
void
syscall_install();
-static void*
-syscall(unsigned int callcode)
-{
- asm volatile("int %0" ::"i"(LUNAIX_SYS_CALL), "D"(callcode) : "eax");
-}
-
#define asmlinkage __attribute__((regparm(0)))
#define __PARAM_MAP1(t1, p1) t1 p1
#include <lunaix/mm/vmm.h>
#include <lunaix/process.h>
#include <lunaix/spike.h>
+#include <lunaix/status.h>
#include <lunaix/syscall.h>
#include <lunaix/syslog.h>
return __current->parent->pid;
}
+__DEFINE_LXSYSCALL(pid_t, getpgid)
+{
+ return __current->pgid;
+}
+
+__DEFINE_LXSYSCALL2(int, setpgid, pid_t, pid, pid_t, pgid)
+{
+ struct proc_info* proc = pid ? get_process(pid) : __current;
+
+ if (!proc) {
+ __current->k_status = LXINVL;
+ return -1;
+ }
+
+ pgid = pgid ? pgid : proc->pid;
+
+ llist_delete(&proc->grp_member);
+ struct proc_info* gruppenfuhrer = get_process(pgid);
+
+ if (!gruppenfuhrer) {
+ __current->k_status = LXINVL;
+ return -1;
+ }
+
+ llist_append(&gruppenfuhrer->grp_member, &proc->grp_member);
+
+ proc->pgid = pgid;
+ return 0;
+}
+
void
init_proc(struct proc_info* pcb)
{
pcb->pid = alloc_pid();
pcb->created = clock_systime();
pcb->state = PROC_CREATED;
+ pcb->pgid = pcb->pid;
}
pid_t
return -1;
}
+ wpid = wpid ? wpid : -__current->pgid;
cpu_enable_interrupt();
repeat:
llist_for_each(proc, n, &__current->children, siblings)
{
- if (!~wpid || proc->pid == wpid) {
+ if (!~wpid || proc->pid == wpid || proc->pgid == -wpid) {
if (proc->state == PROC_TERMNAT && !options) {
status_flags |= PROCTERM;
goto done;
process = &sched_ctx._procs[index];
- // make sure the address is in the range of process table
+ // make sure the reference is relative to process table
llist_init_head(&process->children);
+ llist_init_head(&process->grp_member);
+
// every process is the child of first process (pid=1)
if (process->parent) {
llist_append(&process->parent->children, &process->siblings);