|
72052
|
1 |
(* Title: Pure/ML/ml_pid.ML
|
|
|
2 |
Author: Makarius
|
|
|
3 |
|
|
|
4 |
Native PID for ML process.
|
|
|
5 |
*)
|
|
|
6 |
|
|
|
7 |
signature ML_PID =
|
|
|
8 |
sig
|
|
|
9 |
val get: unit -> int
|
|
|
10 |
end;
|
|
|
11 |
|
|
|
12 |
if ML_System.platform_is_windows then ML
|
|
|
13 |
\<open>
|
|
72114
|
14 |
structure ML_Pid: ML_PID =
|
|
72052
|
15 |
struct
|
|
|
16 |
|
|
|
17 |
val get =
|
|
|
18 |
Foreign.buildCall0
|
|
|
19 |
(Foreign.getSymbol (Foreign.loadLibrary "kernel32.dll") "GetCurrentProcessId", (), Foreign.cInt);
|
|
|
20 |
|
|
|
21 |
end;
|
|
|
22 |
\<close>
|
|
|
23 |
else ML
|
|
|
24 |
\<open>
|
|
72114
|
25 |
structure ML_Pid: ML_PID =
|
|
72052
|
26 |
struct
|
|
|
27 |
|
|
|
28 |
val get = Posix.ProcEnv.getpid #> Posix.Process.pidToWord #> SysWord.toLargeInt
|
|
|
29 |
|
|
|
30 |
end;
|
|
|
31 |
\<close>
|