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-mv/blob/main/seed/host/tests/process.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / host / tests / process.om` 143 lines ยท 1996 bytes Raw Blame History 1 text child "./exec-child" 2 text words "two words" 3 text data "Omega pipe" 4 global packet uchar 4096 5 global status uchar 4 6 global fds uchar 8 7 global buf uchar 32 8 fn fdword off ulong to int 9 x = ulong 0 10 for i ulong 4 11 v = ulong get fds add off i 12 x = or x shl v mul i 8 13 end 14 ret int x 15 end 16 fn exectest to int 17 put packet 0 4 18 put packet 2 uchar len child 19 for i ulong len child 20 put packet add i 4 get child i 21 end 22 n = add len child 6 23 put packet n uchar len words 24 n = add n 2 25 for i ulong len words 26 put packet add n i get words i 27 end 28 n = add n len words 29 put packet n 2 30 put packet add n 2 207 31 put packet add n 3 128 32 n = add n 4 33 pid = fork 34 if lt pid 0 35 ret 1 36 end 37 if eq pid 0 38 r = execprog packet 0 n 39 ret 2 40 end 41 r = waitpid int pid status 0 len status 0 42 if ne r pid 43 ret 3 44 end 45 if or ne get status 0 0 ne get status 1 0 46 ret 4 47 end 48 put packet 0 1 49 put packet 2 4 50 put packet 4 103 51 put packet 5 111 52 put packet 6 110 53 put packet 7 101 54 r = execprog packet 0 8 55 if ne r neg long 2 56 ret 5 57 end 58 ret 0 59 end 60 fn pipetest to int 61 r = pipefds fds 0 len fds 524288 62 if ne r 0 63 ret 11 64 end 65 rd = fdword 0 66 wr = fdword 4 67 r = dupfd wr 96 524288 68 if ne r 96 69 ret 12 70 end 71 r = write 96 data 0 len data 72 if ne r long len data 73 ret 13 74 end 75 r = waitio rd 1 `1000000000` 76 if or lt r 0 eq and r 1 0 77 ret 14 78 end 79 r = read rd buf 0 len buf 80 if ne r long len data 81 ret 15 82 end 83 for i ulong len data 84 if ne get data i get buf i 85 ret 16 86 end 87 end 88 r = fclose 96 89 r = fclose wr 90 r = fclose rd 91 ret 0 92 end 93 fn stoptest to int 94 if le getpid 0 95 ret 21 96 end 97 start = monons 98 r = sleepns `1000000` 99 if ne r 0 100 ret 22 101 end 102 elapsed = sub monons start 103 if lt elapsed `1000000` 104 ret 23 105 end 106 pid = fork 107 if lt pid 0 108 ret 24 109 end 110 if eq pid 0 111 r = sleepns `5000000000` 112 ret 25 113 end 114 r = killpid int pid 15 115 if ne r 0 116 ret 26 117 end 118 r = waitpid int pid status 0 len status 0 119 if ne r pid 120 ret 27 121 end 122 if ne get status 0 15 123 ret 28 124 end 125 ret 0 126 end 127 fn main to int 128 if ne add getpid getpid mul getpid 2 129 ret 41 130 end 131 if ne fclose int socknew 1 1 0 0 132 ret 42 133 end 134 r = exectest 135 if ne r 0 136 ret r 137 end 138 r = pipetest 139 if ne r 0 140 ret r 141 end 142 ret stoptest 143 end