mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-18 15:26:31 +00:00
Estimated hours taken: 2 Branches: main Adds support for the stat, pipe and kill system calls. Renames mode and pid to mode_t and pid_t.
51 lines
1.4 KiB
Mathematica
51 lines
1.4 KiB
Mathematica
%------------------------------------------------------------------------------%
|
|
% Copyright (C) 2001 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU Library General
|
|
% Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
%------------------------------------------------------------------------------%
|
|
%
|
|
% module: posix__kill.m
|
|
% main author: Michael Day <miked@lendtech.com.au>
|
|
%
|
|
%------------------------------------------------------------------------------%
|
|
:- module posix__kill.
|
|
|
|
:- interface.
|
|
|
|
:- import_module int.
|
|
|
|
:- pred kill(pid_t, int, posix__result, io__state, io__state).
|
|
:- mode kill(in, in, out, di, uo) is det.
|
|
|
|
%------------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- pragma c_header_code("
|
|
#include <sys/types.h>
|
|
#include <signal.h>
|
|
").
|
|
|
|
%------------------------------------------------------------------------------%
|
|
|
|
kill(Pid, Sig, Result) -->
|
|
kill0(Pid, Sig, Res),
|
|
( if { Res \= 0 } then
|
|
errno(Err),
|
|
{ Result = error(Err) }
|
|
else
|
|
{ Result = ok }
|
|
).
|
|
|
|
:- pred kill0(pid_t, int, int, io__state, io__state).
|
|
:- mode kill0(in, in, out, di, uo) is det.
|
|
|
|
:- pragma c_code(kill0(Pid::in, Sig::in, Res::out, IO0::di, IO::uo),
|
|
[will_not_call_mercury], "{
|
|
Res = kill(Pid, Sig);
|
|
IO = IO0;
|
|
}").
|
|
|
|
%------------------------------------------------------------------------------%
|
|
|