1 /**
2     Processes
3 
4     Copyright:
5         Copyright © 2023-2025, Kitsunebi Games
6         Copyright © 2023-2025, Inochi2D Project
7     
8     License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
9     Authors:   Luna Nielsen
10 */
11 module nulib.threading.internal.process;
12 import numem;
13 
14 /**
15     A process.
16 */
17 export
18 abstract
19 class NativeProcess : NuObject {
20 public:
21 @nogc:
22 
23     /**
24         The current running process.
25     */
26     static @property NativeProcess thisProcess() @safe => _nu_process_get_self();
27 
28     /**
29         The ID of the process.
30     */
31     abstract @property uint pid() @safe;
32 
33     /**
34         Kills the given process.
35 
36         Returns:
37             $(D true) if the operation succeeded,
38             $(D false) otherwise.
39     */
40     abstract bool kill() @safe;
41 }
42 
43 //
44 //          FOR IMPLEMENTORS
45 //
46 
47 private extern(C):
48 import core.attribute : weak;
49 
50 version(DigitalMars) version = WeakIsBroken;
51 version(linux) version = WeakIsBroken;
52 version(WeakIsBroken) {
53 
54     // Needed on Linux because we can't specify load order.
55     extern(C) extern NativeProcess _nu_process_get_self() @nogc @trusted nothrow;
56 } else {
57     
58     /*
59         Optional helper which gets the current running process.
60     */
61     NativeProcess _nu_process_get_self() @weak @nogc @trusted nothrow {
62         return null;
63     }
64 }