[m-rev.] posix: getpid, getppid

Michael Day mikeday at bigpond.net.au
Thu Aug 23 12:40:39 AEST 2001


Estimated hours taken: 0.25
Branches: main

Add getpid and getppid predicates.

Michael


Index: posix.getpid.m
===================================================================
RCS file: posix.getpid.m
diff -N posix.getpid.m
--- /dev/null	Wed Nov 15 09:24:47 2000
+++ posix.getpid.m	Thu Aug 23 12:40:46 2001
@@ -0,0 +1,52 @@
+%------------------------------------------------------------------------------%
+% 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__getpid.m
+% main author: Michael Day <miked at lendtech.com.au>
+%
+%------------------------------------------------------------------------------%
+:- module posix__getpid.
+
+:- interface.
+
+:- pred getpid(pid_t, io__state, io__state).
+:- mode getpid(out, di, uo) is det.
+
+:- pred getppid(pid_t, io__state, io__state).
+:- mode getppid(out, di, uo) is det.
+
+%------------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int.
+
+:- pragma c_header_code("
+	#include <sys/types.h>
+	#include <unistd.h>
+").
+
+%------------------------------------------------------------------------------%
+
+:- pragma c_code(getpid(Pid::out, IO0::di, IO::uo),
+		[will_not_call_mercury, thread_safe], "
+	Pid = getpid();
+	IO = IO0;
+").
+
+:- pragma c_code(getppid(Pid::out, IO0::di, IO::uo),
+		[will_not_call_mercury, thread_safe], "
+	Pid = getppid();
+	IO = IO0;
+").
+
+%------------------------------------------------------------------------------%
+

Index: posix.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/posix/posix.m,v
retrieving revision 1.4
diff -u -r1.4 posix.m
--- posix.m	2001/07/25 08:37:23	1.4
+++ posix.m	2001/08/23 02:40:46
@@ -37,6 +37,7 @@
 :- include_module posix__dup.
 :- include_module posix__exec.
 :- include_module posix__fork.
+:- include_module posix__getpid.
 :- include_module posix__kill.
 :- include_module posix__lseek.
 :- include_module posix__mkdir.

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list