linux.nim 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import posix
  2. ## Flags of `clone` syscall.
  3. ## See `clone syscall manual
  4. ## <https://man7.org/linux/man-pages/man2/clone.2.html>`_ for more information.
  5. const
  6. CSIGNAL* = 0x000000FF'i32
  7. CLONE_VM* = 0x00000100'i32
  8. CLONE_FS* = 0x00000200'i32
  9. CLONE_FILES* = 0x00000400'i32
  10. CLONE_SIGHAND* = 0x00000800'i32
  11. CLONE_PIDFD* = 0x00001000'i32
  12. CLONE_PTRACE* = 0x00002000'i32
  13. CLONE_VFORK* = 0x00004000'i32
  14. CLONE_PARENT* = 0x00008000'i32
  15. CLONE_THREAD* = 0x00010000'i32
  16. CLONE_NEWNS* = 0x00020000'i32
  17. CLONE_SYSVSEM* = 0x00040000'i32
  18. CLONE_SETTLS* = 0x00080000'i32
  19. CLONE_PARENT_SETTID* = 0x00100000'i32
  20. CLONE_CHILD_CLEARTID* = 0x00200000'i32
  21. CLONE_DETACHED* = 0x00400000'i32
  22. CLONE_UNTRACED* = 0x00800000'i32
  23. CLONE_CHILD_SETTID* = 0x01000000'i32
  24. CLONE_NEWCGROUP* = 0x02000000'i32
  25. CLONE_NEWUTS* = 0x04000000'i32
  26. CLONE_NEWIPC* = 0x08000000'i32
  27. CLONE_NEWUSER* = 0x10000000'i32
  28. CLONE_NEWPID* = 0x20000000'i32
  29. CLONE_NEWNET* = 0x40000000'i32
  30. CLONE_IO* = 0x80000000'i32
  31. # fn should be of type proc (a2: pointer) {.cdecl.}
  32. proc clone*(fn: pointer; child_stack: pointer; flags: cint;
  33. arg: pointer; ptid: ptr Pid; tls: pointer;
  34. ctid: ptr Pid): cint {.importc, header: "<sched.h>".}
  35. proc pipe2*(a: array[0..1, cint], flags: cint): cint {.importc, header: "<unistd.h>".}