Changeset 23 for trunk/kernel/syscalls/sys_signal.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_signal.c
r1 r23 1 1 /* 2 * sys_s em.c: interface to access signal service2 * sys_signal.c - associate a specific signal handler to a given signal. 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012,2013,2014,2015 UPMC Sorbonne Universites 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) 5 * Alain Greiner (2016,2017) 6 * 7 * Copyright (c) UPMC Sorbonne Universites 6 8 * 7 9 * This file is part of ALMOS-kernel. … … 21 23 */ 22 24 23 #include < types.h>25 #include <hal_types.h> 24 26 #include <errno.h> 25 27 #include <thread.h> 26 #include <task.h> 27 #include <pid.h> 28 #include <printk.h> 28 29 #include <signal.h> 29 30 31 ////////////////////////////////// 32 int sys_signal( uint32_t sig_id, 33 void * handler ) 34 { 35 thread_t * this = CURRENT_THREAD; 30 36 31 int sys_signal(uint_t sig, sa_handler_t *handler) 32 { 33 register struct thread_s *this; 34 int retval; 35 36 this = current_thread; 37 38 if((sig == 0) || (sig >= SIG_NR) || (sig == SIGKILL) || (sig == SIGSTOP)) 37 if((sig_id == 0) || (sig_id >= SIG_NR) || (sig_id == SIGKILL) || (sig_id == SIGSTOP)) 39 38 { 40 this->info.errno = EINVAL; 41 return SIG_ERROR; 39 printk("\n[ERROR] in %s : illega signal index = %d\n", __FUNCTION__ , sig_id ); 40 this->errno = EINVAL; 41 return -1; 42 42 } 43 43 44 retval = (int) this->task->sig_mgr.sigactions[sig];45 this-> task->sig_mgr.sigactions[sig] = handler;44 // register handler in signal manager for the calling process 45 this->process->sig_mgr.sigactions[sig_id] = handler; 46 46 47 sig_dmsg(1, "%s: handler @%x has been registred for signal %d\n", 48 __FUNCTION__, 49 handler, 50 sig); 47 signal_dmsg("\n[INFO] %s : handler @%x has been registred for signal %d\n", 48 __FUNCTION__ , handler , sig_id ); 51 49 52 return retval;53 }54 55 56 int sys_sigreturn_setup(void *sigreturn_func)57 {58 struct thread_s *this;59 60 this = current_thread;61 this->info.attr.sigreturn_func = sigreturn_func;62 cpu_context_set_sigreturn(&this->pws, sigreturn_func);63 50 return 0; 64 51 } 65 52 66 67 int sys_kill(pid_t pid, uint_t sig)68 {69 cid_t location;70 error_t err;71 72 if((sig == 0) || (sig >= SIG_NR))73 {74 err = EINVAL;75 }76 else77 {78 if ( PID_GET_CLUSTER(pid) == current_cid )79 location = current_cid;80 else81 location = task_whereis(pid);82 83 err = signal_rise(pid, location, sig);84 85 /* No error, return 0 */86 if (!err)87 return 0;88 }89 90 /* Error. Set errno and return */91 current_thread->info.errno = err;92 return -1;93 }
Note: See TracChangeset
for help on using the changeset viewer.