1760c2415Smrg /* Implementation of the KILL g77 intrinsic.
2*0bfacb9bSmrg    Copyright (C) 2005-2020 Free Software Foundation, Inc.
3760c2415Smrg    Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
4760c2415Smrg 
5760c2415Smrg This file is part of the GNU Fortran runtime library (libgfortran).
6760c2415Smrg 
7760c2415Smrg Libgfortran is free software; you can redistribute it and/or
8760c2415Smrg modify it under the terms of the GNU General Public
9760c2415Smrg License as published by the Free Software Foundation; either
10760c2415Smrg version 3 of the License, or (at your option) any later version.
11760c2415Smrg 
12760c2415Smrg Libgfortran is distributed in the hope that it will be useful,
13760c2415Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
14760c2415Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15760c2415Smrg GNU General Public License for more details.
16760c2415Smrg 
17760c2415Smrg Under Section 7 of GPL version 3, you are granted additional
18760c2415Smrg permissions described in the GCC Runtime Library Exception, version
19760c2415Smrg 3.1, as published by the Free Software Foundation.
20760c2415Smrg 
21760c2415Smrg You should have received a copy of the GNU General Public License and
22760c2415Smrg a copy of the GCC Runtime Library Exception along with this program;
23760c2415Smrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24760c2415Smrg <http://www.gnu.org/licenses/>.  */
25760c2415Smrg 
26760c2415Smrg #include "libgfortran.h"
27760c2415Smrg #include <errno.h>
28760c2415Smrg #include <signal.h>
29760c2415Smrg 
30760c2415Smrg 
31760c2415Smrg /* SUBROUTINE KILL(PID, SIGNAL, STATUS)
32760c2415Smrg    INTEGER, INTENT(IN) :: PID, SIGNAL
33760c2415Smrg    INTEGER(KIND=1), INTENT(OUT), OPTIONAL :: STATUS
34760c2415Smrg 
35760c2415Smrg    INTEGER FUNCTION KILL(PID, SIGNAL)
36760c2415Smrg    INTEGER, INTENT(IN) :: PID, SIGNAL */
37760c2415Smrg 
38760c2415Smrg #ifdef HAVE_KILL
39760c2415Smrg extern void kill_sub (GFC_INTEGER_4, GFC_INTEGER_4, GFC_INTEGER_4 *);
40760c2415Smrg iexport_proto(kill_sub);
41760c2415Smrg 
42760c2415Smrg void
kill_sub(GFC_INTEGER_4 pid,GFC_INTEGER_4 signal,GFC_INTEGER_4 * status)43760c2415Smrg kill_sub (GFC_INTEGER_4 pid, GFC_INTEGER_4 signal, GFC_INTEGER_4 *status)
44760c2415Smrg {
45760c2415Smrg   int val;
46760c2415Smrg 
47760c2415Smrg   val = kill (pid, signal);
48760c2415Smrg 
49760c2415Smrg   if (status != NULL)
50760c2415Smrg     *status = (val == 0) ? 0 : errno;
51760c2415Smrg }
52760c2415Smrg iexport(kill_sub);
53760c2415Smrg 
54760c2415Smrg extern GFC_INTEGER_4 PREFIX (kill) (GFC_INTEGER_4, GFC_INTEGER_4);
55760c2415Smrg export_proto_np(PREFIX (kill));
56760c2415Smrg 
57760c2415Smrg GFC_INTEGER_4
PREFIX(kill)58760c2415Smrg PREFIX (kill) (GFC_INTEGER_4 pid, GFC_INTEGER_4 signal)
59760c2415Smrg {
60760c2415Smrg   int val;
61760c2415Smrg   val = (int)kill (pid, signal);
62760c2415Smrg   return ((val == 0) ? 0 : errno);
63760c2415Smrg }
64760c2415Smrg 
65760c2415Smrg #endif
66