1 /** 2 POSIX Implementation for nulib.threading.internal.process 3 4 Copyright: 5 Copyright © 2025, Kitsunebi Games 6 Copyright © 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.posix.threading.process; 12 import nulib.threading.internal.process; 13 import numem; 14 15 class PosixProcess : NativeProcess { 16 private: 17 @nogc: 18 uint pid_; 19 20 public: 21 22 /** 23 The ID of the process. 24 */ 25 override @property uint pid() @safe => pid_; 26 27 /** 28 Constructs a new PosixProcess. 29 */ 30 this(uint pid) nothrow { 31 this.pid_ = pid; 32 } 33 34 /** 35 Kills the given process. 36 37 Returns: 38 $(D true) if the operation succeeded, 39 $(D false) otherwise. 40 */ 41 override 42 bool kill() @safe { 43 return cast(bool).kill(pid_, SIGTERM); 44 } 45 } 46 47 extern(C) export 48 NativeProcess _nu_process_get_self() @nogc @trusted nothrow { 49 return nogc_new!PosixProcess(.getpid()); 50 } 51 52 // 53 // BINDINGS 54 // 55 extern(C): 56 57 enum SIGTERM = 15; 58 extern uint getpid() @trusted @nogc nothrow; 59 extern int kill(uint, int) @trusted @nogc nothrow;