summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/osproc.nim2
-rw-r--r--tests/stdlib/tosproc.nim13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim
index 512db92a4..666ccdda8 100644
--- a/lib/pure/osproc.nim
+++ b/lib/pure/osproc.nim
@@ -1523,7 +1523,7 @@ elif not defined(useNimRtl):
                                      header: "<stdlib.h>".}
 
   proc execCmd(command: string): int =
-    when defined(linux):
+    when defined(posix):
       let tmp = csystem(command)
       result = if tmp == -1: tmp else: exitStatusLikeShell(tmp)
     else:
diff --git a/tests/stdlib/tosproc.nim b/tests/stdlib/tosproc.nim
index c54e0d112..f55dd3e21 100644
--- a/tests/stdlib/tosproc.nim
+++ b/tests/stdlib/tosproc.nim
@@ -29,6 +29,12 @@ when defined(case_testfile): # compiled test file for child process
     case arg
     of "exit_0":
       if true: quit(0)
+    of "exit_1":
+      if true: quit(1)
+    of "exit_2":
+      if true: quit(2)
+    of "exit_42":
+      if true: quit(42)
     of "exitnow_139":
       if true: exitnow(139)
     of "c_exit2_139":
@@ -115,6 +121,13 @@ else: # main driver
     runTest("c_exit2_139", 139)
     runTest("quit_139", 139)
 
+  block execCmdTest:
+    let output = compileNimProg("-d:release -d:case_testfile", "D20220705T221100")
+    doAssert execCmd(output & " exit_0") == 0
+    doAssert execCmd(output & " exit_1") == 1
+    doAssert execCmd(output & " exit_2") == 2
+    doAssert execCmd(output & " exit_42") == 42
+
   import std/streams
 
   block execProcessTest:
og.md?h=devel&id=e2094bc6f4014d0da38e1bf440236b15023f6aa4'>e2094bc6f ^
1d9343080 ^

e2094bc6f ^
e3e17009f ^
212457f5e ^
5d46e1eaa ^


e3e17009f ^

212fdc594 ^


e3e17009f ^

a1879cae5 ^




16c1a9085 ^



e3e17009f ^

500394225 ^


e3e17009f ^
91cab6dbd ^
4301744e4 ^

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
40
41
42
43
44
45
46
47
48
49
50
51
52