Process.hx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package eval.luv;
  2. import eval.integers.Int64;
  3. /**
  4. File descriptor redirections for use with `eval.luv.Process.spawn`
  5. **/
  6. @:coreType abstract Redirection {}
  7. /**
  8. Options for spawning the process.
  9. **/
  10. typedef ProcessOptions = {
  11. var ?onExit:(p:Process, exitStatus:Int64, termSignal:Int)->Void;
  12. var ?environment:Map<String,NativeString>;
  13. var ?workingDirectory:NativeString;
  14. var ?redirect:Array<Redirection>;
  15. var ?uid:Int;
  16. var ?gid:Int;
  17. var ?windowsVerbatimArguments:Bool;
  18. var ?detached:Bool;
  19. var ?windowsHide:Bool;
  20. var ?windowsHideConsole:Bool;
  21. var ?windowsHideGui:Bool;
  22. }
  23. /**
  24. Subprocesses.
  25. @see https://aantron.github.io/luv/luv/Luv/Process
  26. **/
  27. @:using(eval.luv.Handle)
  28. @:coreType abstract Process to Handle {
  29. extern static public final stdin:Int;
  30. extern static public final stdout:Int;
  31. extern static public final stderr:Int;
  32. /**
  33. Causes `fd` in the child to be connected to `toParentPipe` in the parent.
  34. Binds `UV_CREATE_PIPE`.
  35. `readableInChild` sets `UV_READABLE_PIPE`, and `writableInChild` sets `UV_WRITABLE_PIPE`.
  36. `overlapped` sets `UV_OVERLAPPED_PIPE`.
  37. **/
  38. static public function toParentPipe(fd:Int, parentPipe:Pipe, readableInChild:Bool, writableInChild:Bool, overlapped:Bool):Redirection;
  39. /**
  40. Causes `fd` in the child to be connected to the same device or peer as `fromParentFd` in the parent.
  41. Binds `UV_INHERIT_FD`
  42. **/
  43. static public function inheritFd(fd:Int, fromParentFd:Int):Redirection;
  44. /**
  45. Same as `eval.luv.Process.inheritFd`, but takes an `eval.luv.Stream` for the parent file descriptor.
  46. Binds `UV_INHERIT_STREAM`.
  47. **/
  48. static public function inheritStream(fd:Int, fromParentStream:Stream):Redirection;
  49. /**
  50. Starts a process.
  51. The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
  52. **/
  53. static public function spawn(loop:Loop, cmd:NativeString, args:Array<NativeString>, ?options:ProcessOptions):Result<Process>;
  54. /**
  55. Disables (tries) file descriptor inheritance for inherited descriptors.
  56. **/
  57. static public function disableStdioInheritance():Void;
  58. /**
  59. Sends the given signal to the process with the given pid.
  60. **/
  61. static public function killPid(pid:Int, sigNum:Signal.SigNum):Result<Result.NoData>;
  62. /**
  63. Sends the given signal to the process.
  64. **/
  65. public function kill(sigNum:Signal.SigNum):Result<Result.NoData>;
  66. /**
  67. Evaluates to the pid of the process.
  68. **/
  69. public function pid():Int;
  70. }