source: trunk/src/emx/src/lib/sys/b_signalSendPid.c@ 1629

Last change on this file since 1629 was 1629, checked in by bird, 21 years ago

Signals, processes and stuff.

  • Property cvs2svn:cvs-rev set to 1.4
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: b_signalSendPid.c 1629 2004-11-14 05:28:02Z bird $ */
2/** @file
3 *
4 * LIBC SYS Backend - send signal to process.
5 *
6 * Copyright (c) 2004 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This file is part of InnoTek LIBC.
10 *
11 * InnoTek LIBC is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published
13 * by the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * InnoTek LIBC is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with InnoTek LIBC; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include "libc-alias.h"
32#define INCL_BASE
33#define INCL_FSMACROS
34#define INCL_DOSSIGNALS
35#include <os2emx.h>
36
37#include <signal.h>
38#include <errno.h>
39#include <InnoTekLIBC/backend.h>
40#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_SIGNAL
41#include <InnoTekLIBC/logstrict.h>
42#include "signals.h"
43#include "syscalls.h"
44
45
46/**
47 * Send a signal to a process.
48 *
49 * Special case for iSignalNo equal to 0, where no signal is sent but permissions to
50 * do so is checked.
51 *
52 * @returns 0 on if signal sent.
53 * @returns -errno on failure.
54 *
55 * @param pid Process Id of the process which the signal is to be sent to.
56 * @param iSignalNo The signal to send.
57 * If 0 no signal is sent, but error handling is done as if.
58 */
59int __libc_Back_signalSendPid(pid_t pid, int iSignalNo)
60{
61 LIBCLOG_ENTER("pid=%d iSignalNo=%d\n", pid, iSignalNo);
62 int rc;
63
64 /*
65 * Validate input.
66 */
67 if (!__SIGSET_SIG_VALID(iSignalNo) && iSignalNo != 0)
68 {
69 LIBC_ASSERTM_FAILED("Invalid signal no. %d\n", iSignalNo);
70 LIBCLOG_RETURN_INT(-EINVAL);
71 }
72 if (pid <= 0)
73 {
74 LIBC_ASSERTM_FAILED("Invalid pid %d\n", pid);
75 LIBCLOG_RETURN_INT(-EINVAL);
76 }
77
78 /*
79 * Differ between others and our self.
80 */
81 if (_sys_pid != pid)
82 rc = __libc_back_signalSendPidOther(pid, iSignalNo, NULL);
83 else
84 {
85 if (iSignalNo != 0)
86 {
87 rc = __libc_Back_signalRaise(iSignalNo, NULL, NULL, 0);
88 if (rc > 0)
89 rc = 0;
90 }
91 else /* permission check, succeeded. */
92 rc = 0;
93 }
94 LIBCLOG_RETURN_INT(rc);
95}
96
Note: See TracBrowser for help on using the repository browser.