#include <signal.h>
#include <string.h>
#include <spinlock.h>
+#include <unistd.h>
#include "fd.h"
#include "sched.h"
{
int ret_val;
+ dbg_printf("pg_dir_memcpy(%p, %p, NULL, %p, 0x%08x)\n", proc, dst, src, bytes);
ret_val = pg_dir_memcpy(proc->p_pgdir, dst, NULL, src, bytes);
return(ret_val);
ret_val = -EINVAL;
if(proc && signal > 0 && signal <= SIGUNUSED) {
+ process_t *cproc;
stack_frame_t *kstk;
u32_t *vesp3;
u32_t *pesp3;
task_t *task;
int i;
- /* FIXME: Need to suspend the process in order to deliver the signal safely */
- process_suspend(proc);
+ cproc = process_get_current();
- /*
- * Elect a task to handle the signal - right now, this is simple since the
- * implementation doesn't support more than one task per process, and we
- * can just pick the first (and only) one.
- */
- for(task = NULL, i = 0; i < CONFIG_PROC_MAXTASKS; i++) {
- if(proc->p_tasks[i]) {
- task = proc->p_tasks[i];
- break;
+ if(cproc != proc) {
+ /* FIXME: Need to suspend the process in order to deliver the signal safely */
+ process_suspend(proc);
+
+ /*
+ * Elect a task to handle the signal - right now, this is simple since the
+ * implementation doesn't support more than one task per process, and we
+ * can just pick the first (and only) one.
+ */
+ for(task = NULL, i = 0; i < CONFIG_PROC_MAXTASKS; i++) {
+ if(proc->p_tasks[i]) {
+ task = proc->p_tasks[i];
+ break;
+ }
}
+ } else {
+ /* handle the signal in the current task */
+ task = task_get_current();
}
if(!task) {
return(ret_val);
}
+/*
+ * FIXME: Don't call kernel code from _sig_* functions
+ *
+ * The _sig_* functions will be executed in user-mode after the
+ * process has returned from kernel-mode via iret. Kernel-mode
+ * code will have to be called through the usual syscall interface.
+ */
static void _sig_term(int sig)
{
- process_t *cproc;
-
- cproc = process_get_current();
-
- /* FIXME: terminate the process */
-
+ _exit(sig);
return;
}
static void _sig_core(int sig)
{
- process_t *cproc;
-
- cproc = process_get_current();
-
- /* FIXME: terminate process and generate a core dump */
-
+ _exit(sig);
return;
}
static void _sig_stop(int sig)
{
- process_t *cproc;
-
- cproc = process_get_current();
-
/*
* FIXME: Stop the process
* - Change the process state
*
* Or better yet, make it wait on a lock in the stop handler.
*/
-
return;
}
static void _sig_cont(int sig)
{
- process_t *cproc;
-
- cproc = process_get_current();
-
/*
* FIXME: Continue the process
* - Change its state back to a runnable state