File: texitsignal.nim

package info (click to toggle)
nim 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 462,356 kB
  • sloc: sh: 11,089; ansic: 4,699; makefile: 706; python: 309; sql: 297; asm: 141; xml: 13
file content (39 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
discard """
  output: '''true
true'''
  targets: "c"
"""

import os, osproc
when not defined(windows):
  import posix

# Checks that the environment is passed correctly in startProcess
# To do that launches a copy of itself with a new environment.

if paramCount() == 0:
  # Parent process

  let p = startProcess(
    getAppFilename(),
    args = @["child"],
    options = {poStdErrToStdOut, poUsePath, poParentStreams}
  )

  echo p.running()

  p.kill()

  when defined(windows):
    # windows kill happens using TerminateProcess(h, 0), so we should get a
    # 0 here
    echo p.waitForExit() == 0
  elif defined(haiku):
    # on Haiku, the program main thread receive SIGKILLTHR
    echo p.waitForExit() == 128 + SIGKILLTHR
  else:
    # on posix (non-windows), kill sends SIGKILL
    echo p.waitForExit() == 128 + SIGKILL

else:
  sleep(5000)  # should get killed before this