/**HP**/
uint16_t p_pgrp; /* Process group */
uint8_t p_nice;
+ uint8_t p_event; /* Events */
usize_t p_top; /* Copy of u_top */
#ifdef CONFIG_PROFIL
uint8_t p_profscale;
/* waitpid options */
-#define WNOHANG 1 /* don't support others yet */
-
+#define WNOHANG 1
+#define WUNTRACED 2
+#define _WSTOPPED 0xFF
/* Open() parameters. */
irq = di();
if (proc->p_status != P_EMPTY) { /* Presumably was killed just now */
- /* SIGSTOP can't be ignored and puts the process into P_STOPPED */
- /* FIXME: Level 2 will need a lot more handling here, both SIGTSTP
- handling and the wait() handling for stopping */
+ /* SIGSTOP can't be ignored and puts the process into P_STOPPED.
+ We need to sort out handling of SIGSTOP when waiting - we should
+ really interrupt the syscall and stop */
if (sig == SIGSTOP || sig == SIGTTIN || sig == SIGTTOU) {
if (proc->p_status == P_RUNNING ||
proc->p_status == P_READY)
nready--;
proc->p_status = P_STOPPED;
+ proc->p_event = sig;
/* SIGCONT likewise has an unblockable effect */
} else if (sig == SIGCONT && proc->p_status == P_STOPPED) {
proc->p_status = P_READY;
+ proc->p_event = 0;
nready++;
}
/* Routine signal behaviour */
- else if (!(proc->p_ignored & sigm)) {
+ if (!(proc->p_ignored & sigm)) {
/* Don't wake for held signals */
if (!(proc->p_held & sigm)) {
switch (proc->p_status) {
return -1;
}
for (p = ptab; p < ptab_end; ++p) {
- if (p->p_status == P_ZOMBIE
- && p->p_pptr == udata.u_ptab) {
- if (pid == -1 || p->p_pid == pid
- || p->p_pgrp == -pid) {
+ if (p->p_pptr == udata.u_ptab &&
+ (pid == -1 || p->p_pid == pid ||
+ p->p_pgrp == -pid)) {
+ if (p->p_status == P_ZOMBIE) {
if (statloc)
- uputw(p->p_exitval,
- statloc);
-
+ uputw(p->p_exitval, statloc);
retval = p->p_pid;
p->p_status = P_EMPTY;
udata.u_cstime += ((clock_t *)&p->p_priority)[1];
return retval;
}
+ if (p->p_event && (options & WUNTRACED)) {
+ retval = (uint16_t)p->p_event << 8 | _WSTOPPED;
+ p->p_event = 0;
+ return retval;
+ }
}
}
/* Nothing yet, so wait */