omega-mcp
aien-dev/omega-mcp
Brought by drakestapleton
omega-mcp / data / examples / procs.om
| 1 | note fork, wait, signals, pipes, dup, process groups and sessions, and a failed execprog |
| 2 | global st uchar 4 |
| 3 | global ends uchar 8 |
| 4 | fn ck yes bool to void |
| 5 | if not yes |
| 6 | exit 80 |
| 7 | end |
| 8 | end |
| 9 | fn main to int |
| 10 | ck eq pipefds ends 0 8 0 0 |
| 11 | p = fork |
| 12 | if eq p 0 |
| 13 | exit 7 |
| 14 | end |
| 15 | ck gt p 0 |
| 16 | ck eq waitpid int p st 0 4 0 p |
| 17 | ck eq get st 1 7 |
| 18 | ck eq killpid int getpid 0 0 |
| 19 | ck ge getppid 0 |
| 20 | ck ge getpgid 0 0 |
| 21 | ck ge getsid 0 0 |
| 22 | r = setpgid 0 0 |
| 23 | s = setsid |
| 24 | ck eq dupfd 1 9 0 9 |
| 25 | x = new uchar 6 0 |
| 26 | put x 0 1 |
| 27 | put x 2 2 |
| 28 | put x 4 47 |
| 29 | put x 5 120 |
| 30 | ck eq execprog x 0 6 neg long 2 |
| 31 | ck eq execpure x 0 6 neg long 2 |
| 32 | ret 0 |
| 33 | end |