source: trunk/kernel/ksh/kill.c@ 204

Last change on this file since 204 was 1, checked in by alain, 10 years ago

First import

File size: 1.5 KB
Line 
1/*
2 This file is part of MutekP.
3
4 MutekP is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 MutekP is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with MutekP; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
18 UPMC / LIP6 / SOC (c) 2008
19 Copyright Ghassan Almaless <ghassan.almaless@gmail.com>
20*/
21
22#include <kminiShell.h>
23#include <list.h>
24#include <thread.h>
25#include <task.h>
26#include <signal.h>
27
28error_t kill_func(void *param)
29{
30 ms_args_t *args;
31 uint32_t argc;
32 uint_t sig;
33 pid_t pid;
34 cid_t location;
35 error_t err;
36
37 args = (ms_args_t *) param;
38 argc = args->argc;
39 err = 0;
40
41 if(argc != 3)
42 {
43 ksh_print("Missing signal number or process pid\n");
44 return EINVAL;
45 }
46
47 sig = atoi(args->argv[1]);
48 pid = atoi(args->argv[2]);
49
50 if((sig == 0) || (sig >= SIG_NR))
51 {
52 ksh_print("Unknown signal number: %d\n", sig);
53 return EINVAL;
54 }
55
56 location = task_whereis(pid);
57
58 if((err = signal_rise(pid, location, sig)))
59 ksh_print("Failed to rise signal %d on task %d\n", sig, pid);
60
61 return err;
62}
Note: See TracBrowser for help on using the repository browser.