Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-harness/blob/main/examples/execenv.om # omega-harness Agent skills for operating, encoding and communicating in Omega (.om) and the AIEN repositories Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-harness / examples / execenv.om` 79 lines ยท 1640 bytes Raw Blame History 1 note execenv (keyword 233, omega-mv #1074): execprog with a private environment packet. 2 note The parent re-executes /proc/self/exe with argv [/proc/self/exe, "child"] and an environment 3 note of exactly one record GREETING=hi, in a forked child. The child prints its whole environment; 4 note the parent exits with the child's exit status. A missing program returns -2 (ENOENT). 5 om2 6 text self "/proc/self/exe" 7 text cmode "child" 8 text greet "GREETING=hi" 9 text missing "/nonexistent/omega-execenv-example" 10 global argv uchar 256 11 global envp uchar 64 12 global buf uchar 256 13 global status uchar 4 14 15 fn arec pos ulong s view uchar * to ulong 16 put argv pos uchar and len s 255 17 put argv add pos 1 uchar shr len s 8 18 for i ulong len s 19 put argv add add pos 2 i get s i 20 end 21 ret add add pos 2 len s 22 end 23 24 fn erec pos ulong s view uchar * to ulong 25 put envp pos uchar and len s 255 26 put envp add pos 1 uchar shr len s 8 27 for i ulong len s 28 put envp add add pos 2 i get s i 29 end 30 ret add add pos 2 len s 31 end 32 33 fn child to int 34 c = ulong envcnt 35 for i ulong c 36 n = envread i buf 0 len buf 37 if le n 0 38 ret 2 39 end 40 put buf n 10 41 w = write 1 buf 0 add ulong n 1 42 end 43 if ne c 1 44 ret 1 45 end 46 ret 0 47 end 48 49 fn main to int 50 n = argcnt 51 if eq n 2 52 ret child 53 end 54 put argv 0 2 55 put argv 1 0 56 an = arec 2 self 57 an = arec an cmode 58 put envp 0 1 59 put envp 1 0 60 en = erec 2 greet 61 pid = fork 62 if eq pid 0 63 r = execenv argv 0 an envp 0 en 64 exit 3 65 end 66 w = waitpid int pid status 0 len status 0 67 if ne w pid 68 ret 4 69 end 70 note A missing program: execenv returns -2 (ENOENT) to the caller. 71 put argv 0 1 72 put argv 1 0 73 mn = arec 2 missing 74 r = execenv argv 0 mn envp 0 en 75 if ne r neg long 2 76 ret 5 77 end 78 ret int get status 1 79 end