Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / pid.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 2009 Matthew Fluet.
2 * Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9structure Pid: PID =
10 struct
11 local open Posix.Process
12 in
13 type t = pid
14 val toString = SysWord.fmt StringCvt.DEC o pidToWord
15 fun fromString s =
16 Option.map(Pervasive.Int.fromString s, wordToPid o SysWord.fromInt)
17 end
18
19 val layout = Layout.str o toString
20
21 local open Posix.ProcEnv
22 in
23 val current = getpid
24 val parent = getppid
25 end
26
27 val equals = op =
28 end