raz / commit 22233765

commit
22233765b926c2dfa9435aa10162424942ce093b
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
82f30b3c
Sys: mapRead and protect; open, openMode, openRead, create and openDir close on exec

mapRead maps a file open only to read, protect sets the access of
pages. The files open gives are now closed in a program exec starts,
as pipe's are, and keepOnExec(fd, true) keeps one; spawn is unchanged
since it closes all but its fds and more. No caller in lib, src, tools,
examples or test relied on it. In both backends; tests in Sys.main,
ExecOpened and ExecOpenedC.

patch · log

8 files changed, +206 -31

doc/raz-lib.md (history) modified +28 -10

@@ -16,7 +16,7 @@
1616 | Module | What |
1717 |---|---|
1818 | `Rt` | ending the program, `exit`, `exitStatus` and `atExit`; `stop`, which ends it with a message; `trace`, the calls under way; what the compiler's checks call when they fail |
19-| `Sys` | system calls: `open`, `openMode`, `openRead`, `create`, `read`, `write`, `seek`, `position`, `truncate`, `sync`, `syncAll`, `lock`, `lockShared`, `close`, `closeChecked`, `dup`, `dupTo`, `dupAbove`, `keepOnExec`, `mmap`, `munmap`, `isTerminal`, `yield`, `exit`; files and directories, `rename`, `remove`, `removeDir`, `makeDir`, `makeDirMode`, `chmod`, `setTime`, `access`, `umask`, `symlink`, `readLink`, `info`, `linkInfo`, `infoOf`, `openDir`, `nextEntry`, `entryKind`, `closeDir`; the terminal, `rawMode`, `restoreMode`, `getMode`, `setMode`, `termSize`, `ready`; the environment, `env`, `findEnv`, `envAt`, `setEnv`, `workDir`, `setWorkDir`; programs, `spawn`, `exec` and `execve`, pipes and signals; the user, the machine, time used and limits; time, `clock`, `now`, `sleep`; `random`; errors, by name, and what one means, `errorText`; sockets, among them datagrams served and files passed; and memory shared through a file. One file per target, and `Sys.raz` over the C library for the others, which takes what each C library fixes from `CAbi` |
19+| `Sys` | system calls: `open`, `openMode`, `openRead`, `create`, `read`, `write`, `seek`, `position`, `truncate`, `sync`, `syncAll`, `lock`, `lockShared`, `close`, `closeChecked`, `dup`, `dupTo`, `dupAbove`, `keepOnExec`, `mmap`, `munmap`, `mapRead`, `protect`, `isTerminal`, `yield`, `exit`; files and directories, `rename`, `remove`, `removeDir`, `makeDir`, `makeDirMode`, `chmod`, `setTime`, `access`, `umask`, `symlink`, `readLink`, `info`, `linkInfo`, `infoOf`, `openDir`, `nextEntry`, `entryKind`, `closeDir`; the terminal, `rawMode`, `restoreMode`, `getMode`, `setMode`, `termSize`, `ready`; the environment, `env`, `findEnv`, `envAt`, `setEnv`, `workDir`, `setWorkDir`; programs, `spawn`, `exec` and `execve`, pipes and signals; the user, the machine, time used and limits; time, `clock`, `now`, `sleep`; `random`; errors, by name, and what one means, `errorText`; sockets, among them datagrams served and files passed; and memory shared through a file. One file per target, and `Sys.raz` over the C library for the others, which takes what each C library fixes from `CAbi` |
2020 | `Out` | writing text and numbers to standard output, buffered; safe to call from several threads |
2121 | `C` | the parts of the C library the others use, and `printf`, `fflush`, `stdout`, `pthread_create`; a program that imports it uses C |
2222 | `Lock` | a lock for short sections, for C's threads and `Thread`'s alike |
@@ -256,7 +256,7 @@
256256
257257 proc write*(fd: INT; s: []U8): INT; (* the bytes written *)
258258 proc read*(fd: INT; buf: []U8): INT; (* the bytes read; 0 at the end *)
259-proc open*(path: []U8; how: Accesses): INT; (* its fd *)
259+proc open*(path: []U8; how: Accesses): INT; (* its fd, closed on exec *)
260260 proc openMode*(path: []U8; how: Accesses; mode: INT): INT; (* open, a file it makes given mode *)
261261 proc openRead*(path: []U8): INT; (* open(path, {reading}) *)
262262 proc create*(path: []U8): INT; (* open(path, {writing, creating, truncating}) *)
@@ -272,8 +272,10 @@
272272 proc dup*(fd: INT): INT; (* a new fd for the same file, the lowest free *)
273273 proc dupTo*(fd, into: INT): INT; (* into made the same file as fd, closing what it was *)
274274 proc dupAbove*(fd, least: INT): INT; (* a new fd for the same file, the lowest free from least on, closed on exec *)
275-proc keepOnExec*(fd: INT; yes: BOOL): INT; (* fd left open, or not, in the program exec runs *)
275+proc keepOnExec*(fd: INT; yes: BOOL): INT; (* fd left open, or not (as at first for a file made by open or pipe), in the program exec runs *)
276276 proc isTerminal*(fd: INT): BOOL;
277+proc mapRead*(fd, size: INT): ^U8; (* the first size bytes of fd, which may be open only to read, mapped read only; or nil *)
278+proc protect*(p: ^U8; size: INT; read, write: BOOL): INT; (* the pages at p readable and writable as asked; neither, and touching them stops the program *)
277279 proc mmap*(size: INT): ^U8; (* size bytes of zeroed memory, in whole pages; or nil *)
278280 proc munmap*(p: ^U8; size: INT);
279281 proc yield*; (* the processor given to another thread *)
@@ -501,8 +503,10 @@
501503 shell's `exec cmd` does, found and started as `spawn` would start it,
502504 `p.tty`, `p.group`, `p.foreground`, `p.fds` and `p.dir` included,
503505 except that it keeps this program's other open files: each stays open
504-in the program unless `keepOnExec(fd, false)` was said of it, as it is
505-of `pipe`'s, and those of `p.more` are kept. It returns only if the
506+in the program unless it is closed on exec, as the files `open`,
507+`pipe`, a socket or `memFile` gives are, unless `keepOnExec(fd, true)`
508+was said of them; `dup` and `dupTo` give files that stay open; and
509+those of `p.more` are kept. It returns only if the
506510 program can't run: -2 (ENOENT) or -13 (EACCES) if there is none to
507511 run, with nothing done; or, if the program is found but won't start,
508512 minus the errno, with what `p` asks of the terminal, the group, the
@@ -533,11 +537,16 @@
533537 `access` says whether this user, by its real ids, may read, write or
534538 execute a file, as `test -r`, `-w` and `-x` ask, which `Info.mode`
535539 alone can't say; an empty `how` asks only whether it is there.
536-`open` refuses `executing`, with -22 (EINVAL). `nonblocking` opens a file without waiting: a fifo opened to write
537-waits for a reader and a fifo opened to read waits for a writer, but
538-with `nonblocking` the open returns at once (-6, ENXIO, for a write
539-with no reader), and a read or write that would wait is -11 later, as
540-`setBlocking(fd, false)` makes it. `umask` sets the bits
540+`open` refuses `executing`, with -22 (EINVAL). `nonblocking` opens a
541+file without waiting: a fifo opened to write waits for a reader and a
542+fifo opened to read waits for a writer, but with `nonblocking` the open
543+returns at once (-6, ENXIO, for a write with no reader), and a read or
544+write that would wait is -11 later, as `setBlocking(fd, false)` makes
545+it. A file `open`, `openMode`, `openRead` or `create` gives is closed in
546+a program `exec` or `execve` starts, as `pipe`'s are, so that a fifo or
547+a log one program holds doesn't reach every program it runs;
548+`keepOnExec(fd, true)` keeps one open, and `spawn` is unchanged, since
549+it passes its `fds` and `more` as before. `umask` sets the bits
541550 taken away from the mode of every file this program, and those it
542551 starts, make, and says what they were. `envAt` gives the environment
543552 one variable at a time, from 0, for a shell to list it and to pass it
@@ -653,6 +662,15 @@
653662 what one program writes there another sees at once: so a program hands
654663 an X server or a Wayland compositor its pixels, by `sendFds` of a
655664 `memFile` both map, rather than by copying them down a socket.
665+`mapFile` needs a file open to read and write; `mapRead` maps one that
666+is open only to read, a dictionary that isn't the user's to write, for
667+reading only: a write there stops the program. `protect` changes what
668+may be done with pages `mmap` gave, from a page boundary: read, write,
669+both, or neither, so that touching them stops the program, as a guard
670+page after a buffer does, or a reserve mapped in full and opened as it
671+fills. It takes the address as the system does, so with a C library it
672+is that library's whether an address not on a page boundary is -22
673+(EINVAL) or rounded down.
656674
657675 `readyOf` waits on several file descriptors at once, as a program does
658676 that listens to a server and a terminal both; a descriptor at its end,

lib/C.raz (history) modified +1 -0

@@ -10,6 +10,7 @@
1010 extern proc close*(fd: I32): I32;
1111 extern proc mmap*(addr: ^U8; n: UINT; prot, flags, fd: I32; off: I64): ^U8;
1212 extern proc munmap*(addr: ^U8; n: UINT): I32;
13+extern proc mprotect*(addr: ^U8; n: UINT; prot: I32): I32;
1314 extern proc isatty*(fd: I32): I32;
1415 extern proc exit*(status: I32);
1516 extern proc _exit*(status: I32);

lib/Sys.linux-x86_64.raz (history) modified +70 -11

@@ -193,11 +193,11 @@
193193 return true;
194194 end;
195195
196-(* open's flags for how; Linux's numbers *)
196+(* open's flags for how, with O_CLOEXEC; Linux's numbers *)
197197 proc flags(how: Accesses): I32;
198198 var f: I32;
199199 begin
200- f := 0; (* O_RDONLY *)
200+ f := 80000H; (* O_CLOEXEC, with O_RDONLY *)
201201 if writing in how then
202202 f := 1; (* O_WRONLY *)
203203 if reading in how then f := 2; end; (* O_RDWR *)
@@ -210,9 +210,9 @@
210210 return f;
211211 end;
212212
213-(* The file at path, opened as how asks: its file descriptor, or minus
214- an errno. A file it creates has the permission bits mode, less
215- those the umask takes away. *)
213+(* The file at path, opened as how asks: its file descriptor, closed in
214+ a program exec starts, or minus an errno. A file it creates has the
215+ permission bits mode, less those the umask takes away. *)
216216 proc openMode*(path: []U8; how: Accesses; mode: INT): INT;
217217 var buf: [4096]U8;
218218 begin
@@ -228,13 +228,15 @@
228228 return openMode(path, how, 1A4H); (* 644 *)
229229 end;
230230
231-(* The file at path, opened for reading. *)
231+(* The file at path, opened for reading, closed in a program exec
232+ starts. *)
232233 proc openRead*(path: []U8): INT;
233234 begin
234235 return open(path, {reading});
235236 end;
236237
237-(* The file at path, made empty or new, opened for writing. *)
238+(* The file at path, made empty or new, opened for writing, closed in a
239+ program exec starts. *)
238240 proc create*(path: []U8): INT;
239241 begin
240242 return open(path, {writing, creating, truncating});
@@ -337,7 +339,8 @@
337339 end;
338340
339341 (* Whether fd stays open in the program exec runs in this one's place:
340- yes, or no, closed then, as pipe's fds are at first. 0, or minus an
342+ yes, or no, closed then, as the fds open, pipe and socket give are at
343+ first. 0, or minus an
341344 errno. *)
342345 proc keepOnExec*(fd: INT; yes: BOOL): INT;
343346 var f: INT;
@@ -388,6 +391,29 @@
388391 return ^U8(p);
389392 end;
390393
394+(* The first size bytes of the file fd, which may be open only to
395+ read, mapped to be read only: writing there stops the program. nil
396+ if it can't be; munmap gives them back. *)
397+proc mapRead*(fd, size: INT): ^U8;
398+var p: INT;
399+begin
400+ p := SYSCALL(9, 0, size, 1, 2, fd, 0); (* mmap: read; MAP_PRIVATE *)
401+ if p < 0 then return nil; end;
402+ return ^U8(p);
403+end;
404+
405+(* Lets the pages from p, size bytes from a page boundary, be read and
406+ written as read and write say; neither, and touching them stops the
407+ program. 0, or minus an errno. *)
408+proc protect*(p: ^U8; size: INT; read, write: BOOL): INT;
409+var prot: INT;
410+begin
411+ prot := 0; (* PROT_NONE *)
412+ if read then prot := 1; end;
413+ if write then prot := prot | 2; end;
414+ return SYSCALL(10, p, size, prot); (* mprotect *)
415+end;
416+
391417 (* Whether the file descriptor fd is a terminal: whether it has a
392418 terminal's settings to read (ioctl TCGETS). *)
393419 proc isTerminal*(fd: INT): BOOL;
@@ -593,7 +619,7 @@
593619 d.pos := 0;
594620 d.len := 0;
595621 if not cstr(path, a) then return -36; end;
596- d.fd := SYSCALL(2, ADR(a), 10000H); (* open, O_RDONLY, O_DIRECTORY *)
622+ d.fd := SYSCALL(2, ADR(a), 90000H); (* open, O_RDONLY, O_DIRECTORY, O_CLOEXEC *)
597623 if d.fd < 0 then return d.fd; end;
598624 return 0;
599625 end;
@@ -1770,7 +1796,11 @@
17701796 if p.foreground then _ := foreground(0, SYSCALL(111)); end; (* getpgrp *)
17711797 end;
17721798 for i := 0 to 2 do
1773- if p.fds[i] # 0 then _ := SYSCALL(33, p.fds[i], i); end; (* dup2 *)
1799+ if p.fds[i] = i then
1800+ _ := keepOnExec(i, true); (* dup2 of a file onto itself would leave it closed on exec *)
1801+ elsif p.fds[i] # 0 then
1802+ _ := SYSCALL(33, p.fds[i], i); (* dup2 *)
1803+ end;
17741804 end;
17751805 if LEN(p.dir) > 0 then return SYSCALL(80, ADR(dir[0])); end; (* chdir *)
17761806 return 0;
@@ -1836,7 +1866,8 @@
18361866
18371867 (* Runs the program p describes in this one's place, as spawn would
18381868 start it, but keeping this program's other fds as they are, open
1839- unless keepOnExec said no; the fds of p.more are kept. It returns
1869+ unless closed on exec (as open and pipe give) and not kept by
1870+ keepOnExec; the fds of p.more are kept. It returns
18401871 only if it can't: -2 (ENOENT) or -13 (EACCES) if there is no
18411872 program to run, before anything is done; or, once the program's
18421873 terminal, group, fds and working directory are as p asks, which
@@ -2398,6 +2429,33 @@
23982429 _ := remove("/tmp/raz-sys-fifo");
23992430 end;
24002431
2432+(* The test of memory and files mapped: a file open only to read, mapped
2433+ to be read, and not to be written; and pages that change what may be
2434+ done with them. *)
2435+proc testMaps;
2436+var fd: INT; p, q: ^U8;
2437+begin
2438+ fd := create("/tmp/raz-sys-map");
2439+ if (fd < 0) or (write(fd, "hello") # 5) then exit(2); end;
2440+ close(fd);
2441+ fd := openRead("/tmp/raz-sys-map");
2442+ if (fd < 0) or (mapFile(fd, 5) # nil) then exit(2); end; (* shared and writable: not for a file open to read *)
2443+ p := mapRead(fd, 5);
2444+ if (p = nil) or (p[0..5] # "hello") then exit(2); end;
2445+ munmap(p, 5);
2446+ close(fd);
2447+ _ := remove("/tmp/raz-sys-map");
2448+ p := mmap(8192);
2449+ if p = nil then exit(2); end;
2450+ p[0] := 1;
2451+ q := p + 4096;
2452+ if (protect(q, 4096, true, false) # 0) or (q[0] # 0) then exit(2); end;
2453+ if protect(q, 4096, true, true) # 0 then exit(2); end;
2454+ q[0] := 2;
2455+ if (protect(p, 4096, false, false) # 0) or (protect(p, 4096, true, true) # 0) or (p[0] # 1) then exit(2); end; (* its bytes stay *)
2456+ munmap(p, 8192);
2457+end;
2458+
24012459 (* The module's test: a file written, read back and closed; a
24022460 directory made, listed and emptied; no terminal; a socket, sent to
24032461 after its end; programs; time and the network. *)
@@ -2626,6 +2684,7 @@
26262684 testNet;
26272685 testProcess;
26282686 testServer;
2687+ testMaps;
26292688 end;
26302689
26312690 end Sys.

lib/Sys.raz (history) modified +70 -10

@@ -234,11 +234,11 @@
234234 return true;
235235 end;
236236
237-(* open's flags for how *)
237+(* open's flags for how, with O_CLOEXEC *)
238238 proc flags(how: Accesses): I32;
239239 var f: I32;
240240 begin
241- f := CAbi.oRdonly;
241+ f := CAbi.oRdonly | CAbi.oCloexec;
242242 if writing in how then
243243 f := CAbi.oWronly;
244244 if reading in how then f := CAbi.oRdwr; end;
@@ -251,9 +251,9 @@
251251 return f;
252252 end;
253253
254-(* The file at path, opened as how asks: its file descriptor, or minus
255- an errno. A file it creates has the permission bits mode, less
256- those the umask takes away. *)
254+(* The file at path, opened as how asks: its file descriptor, closed in
255+ a program exec starts, or minus an errno. A file it creates has the
256+ permission bits mode, less those the umask takes away. *)
257257 proc openMode*(path: []U8; how: Accesses; mode: INT): INT;
258258 var buf: [4096]U8; r: INT;
259259 begin
@@ -271,13 +271,15 @@
271271 return openMode(path, how, 1A4H); (* 644 *)
272272 end;
273273
274-(* The file at path, opened for reading. *)
274+(* The file at path, opened for reading, closed in a program exec
275+ starts. *)
275276 proc openRead*(path: []U8): INT;
276277 begin
277278 return open(path, {reading});
278279 end;
279280
280-(* The file at path, made empty or new, opened for writing. *)
281+(* The file at path, made empty or new, opened for writing, closed in a
282+ program exec starts. *)
281283 proc create*(path: []U8): INT;
282284 begin
283285 return open(path, {writing, creating, truncating});
@@ -408,7 +410,8 @@
408410 end;
409411
410412 (* Whether fd stays open in the program exec runs in this one's place:
411- yes, or no, closed then, as pipe's fds are at first. 0, or minus an
413+ yes, or no, closed then, as the fds open, pipe and socket give are at
414+ first. 0, or minus an
412415 errno. *)
413416 proc keepOnExec*(fd: INT; yes: BOOL): INT;
414417 var f: I32;
@@ -463,6 +466,30 @@
463466 return p;
464467 end;
465468
469+(* The first size bytes of the file fd, which may be open only to
470+ read, mapped to be read only: writing there stops the program. nil
471+ if it can't be; munmap gives them back. *)
472+proc mapRead*(fd, size: INT): ^U8;
473+var p: ^U8;
474+begin
475+ p := C.mmap(nil, UINT(size), CAbi.protRead, CAbi.mapPrivate, I32(fd), 0);
476+ if INT(p) = -1 then return nil; end;
477+ return p;
478+end;
479+
480+(* Lets the pages from p, size bytes from a page boundary, be read and
481+ written as read and write say; neither, and touching them stops the
482+ program. 0, or minus an errno. *)
483+proc protect*(p: ^U8; size: INT; read, write: BOOL): INT;
484+var prot: I32;
485+begin
486+ prot := 0; (* PROT_NONE *)
487+ if read then prot := CAbi.protRead; end;
488+ if write then prot := prot | CAbi.protWrite; end;
489+ if C.mprotect(p, UINT(size), prot) # 0 then return failed(); end;
490+ return 0;
491+end;
492+
466493 (* Renames old to new, replacing what new names: 0, or minus an errno. *)
467494 proc rename*(old, new: []U8): INT;
468495 var a, b: [4096]U8;
@@ -1659,7 +1686,11 @@
16591686 if p.foreground then _ := C.tcsetpgrp(0, C.getpgrp()); end;
16601687 end;
16611688 for i := 0 to 2 do
1662- if p.fds[i] # 0 then _ := C.dup2(I32(p.fds[i]), I32(i)); end;
1689+ if p.fds[i] = i then
1690+ _ := keepOnExec(i, true); (* dup2 of a file onto itself would leave it closed on exec *)
1691+ elsif p.fds[i] # 0 then
1692+ _ := C.dup2(I32(p.fds[i]), I32(i));
1693+ end;
16631694 end;
16641695 if (LEN(p.dir) > 0) and (C.chdir(ADR(dir[0])) # 0) then return failed(); end;
16651696 return 0;
@@ -1738,7 +1769,8 @@
17381769
17391770 (* Runs the program p describes in this one's place, as spawn would
17401771 start it, but keeping this program's other fds as they are, open
1741- unless keepOnExec said no; the fds of p.more are kept. It returns
1772+ unless closed on exec (as open and pipe give) and not kept by
1773+ keepOnExec; the fds of p.more are kept. It returns
17421774 only if it can't: -2 (ENOENT) or -13 (EACCES) if there is no
17431775 program to run, before anything is done; or, once the program's
17441776 terminal, group, fds and working directory are as p asks, which
@@ -2343,6 +2375,33 @@
23432375 _ := remove("/tmp/raz-sys-fifo");
23442376 end;
23452377
2378+(* The test of memory and files mapped: a file open only to read, mapped
2379+ to be read, and not to be written; and pages that change what may be
2380+ done with them. *)
2381+proc testMaps;
2382+var fd: INT; p, q: ^U8;
2383+begin
2384+ fd := create("/tmp/raz-sys-map");
2385+ if (fd < 0) or (write(fd, "hello") # 5) then exit(2); end;
2386+ close(fd);
2387+ fd := openRead("/tmp/raz-sys-map");
2388+ if (fd < 0) or (mapFile(fd, 5) # nil) then exit(2); end; (* shared and writable: not for a file open to read *)
2389+ p := mapRead(fd, 5);
2390+ if (p = nil) or (p[0..5] # "hello") then exit(2); end;
2391+ munmap(p, 5);
2392+ close(fd);
2393+ _ := remove("/tmp/raz-sys-map");
2394+ p := mmap(8192);
2395+ if p = nil then exit(2); end;
2396+ p[0] := 1;
2397+ q := p + 4096;
2398+ if (protect(q, 4096, true, false) # 0) or (q[0] # 0) then exit(2); end;
2399+ if protect(q, 4096, true, true) # 0 then exit(2); end;
2400+ q[0] := 2;
2401+ if (protect(p, 4096, false, false) # 0) or (protect(p, 4096, true, true) # 0) or (p[0] # 1) then exit(2); end; (* its bytes stay *)
2402+ munmap(p, 8192);
2403+end;
2404+
23462405 (* The module's test, as Linux's Sys has it: a file written, read back
23472406 and closed; a directory made, listed and emptied; no terminal; a
23482407 socket, sent to after its end; programs; time and the network. *)
@@ -2570,6 +2629,7 @@
25702629 testNet;
25712630 testProcess;
25722631 testServer;
2632+ testMaps;
25732633 end;
25742634
25752635 end Sys.

test/libc/ExecOpenedC.expect (history) added +2 -0

@@ -0,0 +1,2 @@
1+closed 3
2+open 4

test/libc/ExecOpenedC.raz (history) added +17 -0

@@ -0,0 +1,17 @@
1+(* Over the C library: a file open gives is closed in the program exec
2+ runs, unless keepOnExec says to keep it: of two opened files, sh sees
3+ the second. *)
4+module ExecOpenedC;
5+import Sys;
6+
7+proc main*: INT;
8+var a, b: INT;
9+begin
10+ a := Sys.openRead("/dev/null");
11+ b := Sys.create("/dev/null");
12+ if (a # 3) or (b # 4) or (Sys.keepOnExec(b, true) # 0) then return 1; end;
13+ return Sys.exec({path: "sh",
14+ args: ["sh", "-c", "for n in 3 4; do if [ -e /proc/self/fd/$n ]; then echo open $n; else echo closed $n; fi; done"]});
15+end;
16+
17+end ExecOpenedC.

test/run/ExecOpened.expect (history) added +2 -0

@@ -0,0 +1,2 @@
1+closed 3
2+open 4

test/run/ExecOpened.raz (history) added +16 -0

@@ -0,0 +1,16 @@
1+(* A file open gives is closed in the program exec runs, unless
2+ keepOnExec says to keep it: of two opened files, sh sees the second. *)
3+module ExecOpened;
4+import Sys;
5+
6+proc main*: INT;
7+var a, b: INT;
8+begin
9+ a := Sys.openRead("/dev/null");
10+ b := Sys.create("/dev/null");
11+ if (a # 3) or (b # 4) or (Sys.keepOnExec(b, true) # 0) then return 1; end;
12+ return Sys.exec({path: "sh",
13+ args: ["sh", "-c", "for n in 3 4; do if [ -e /proc/self/fd/$n ]; then echo open $n; else echo closed $n; fi; done"]});
14+end;
15+
16+end ExecOpened.