Signal.hx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package eval.luv;
  2. /**
  3. For the moment, the signals exposed are those that are both present on Unix
  4. and present or emulated by libuv on Windows.
  5. You can also provide a plain integer signal code instead of the values of
  6. this enum.
  7. @see https://aantron.github.io/luv/luv/Luv/Signal#signals
  8. **/
  9. extern enum abstract SigNum(Int) from Int to Int {
  10. var SIGABRT;
  11. var SIGFPE;
  12. var SIGHUP;
  13. var SIGILL;
  14. var SIGINT;
  15. var SIGKILL;
  16. var SIGSEGV;
  17. var SIGTERM;
  18. var SIGWINCH;
  19. }
  20. /**
  21. Signals.
  22. @see https://aantron.github.io/luv/luv/Luv/Signal
  23. **/
  24. @:using(eval.luv.Handle)
  25. @:coreType abstract Signal to Handle {
  26. /**
  27. Allocates and initializes a signal handle.
  28. The handle should be cleaned up with `eval.luv.Handle.close` when no longer needed.
  29. **/
  30. static public function init(loop:Loop):Result<Signal>;
  31. /**
  32. Starts the signal handle.
  33. **/
  34. public function start(sigNum:SigNum, callback:()->Void):Result<Result.NoData>;
  35. /**
  36. Like `eval.luv.Signal.start`, but the handle is stopped after one callback call.
  37. **/
  38. public function startOneshot(sigNum:SigNum, callback:()->Void):Result<Result.NoData>;
  39. /**
  40. Stops the signal handle.
  41. **/
  42. public function stop():Result<Result.NoData>;
  43. /**
  44. Evaluates to the signal number associated with the handle.
  45. **/
  46. public function signum():Int;
  47. }