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/interplane-forge/blob/main/infra/test/hog.om # interplane-forge INTERPLANE Forge 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 `interplane-forge / infra / test / hog.om` 116 lines ยท 2110 bytes Raw Blame History 1 om2 2 note hog (test-only, sandbox gate). Runs inside the sandbox in place of forged. 3 note hog fork : fork up to 4096 children that each sleep 5 s; stop at the first refusal. 4 note Prints "forks N error E". Exit 0 when a fork was refused, 1 when all 4096 ran. 5 note hog file PATH : write 1 MiB blocks to PATH, up to 4096 blocks (4 GiB). A file-size limit 6 note kills it with SIGXFSZ, or a write fails. Exit 0 on a failed write, 1 when 7 note all 4 GiB were written. 8 note Linux ARM64: O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC = 1|64|512|524288 = 524865; mode 0600 = 384. 9 global arg uchar 4096 10 global blk uchar `1048576` 11 global num uchar 32 12 global ws uchar 4 13 text tfork "fork" 14 text tfile "file" 15 text tforks "forks " 16 text terr " error " 17 text twrote "wrote " 18 text tnl "\n" 19 fn putdec v ulong to void 20 x = v 21 i = ulong 32 22 while gt i 0 bound 32 23 i = sub i 1 24 put num i add uchar rem x 10 48 25 x = div x 10 26 if eq x 0 27 break 28 end 29 end 30 k = write 1 num i sub 32 i 31 end 32 fn same n ulong t view uchar * to bool 33 if ne n len t 34 ret false 35 end 36 for i ulong n bound 4096 37 if ne get arg i get t i 38 ret false 39 end 40 end 41 ret true 42 end 43 fn forks to int 44 n = ulong 0 45 e = long 0 46 while lt n 4096 bound 4096 47 p = fork 48 if eq p 0 49 s = sleepns `5000000000` 50 exit 0 51 end 52 if lt p 0 53 e = p 54 break 55 end 56 n = add n 1 57 end 58 k = write 1 tforks 0 len tforks 59 putdec n 60 k = write 1 terr 0 len terr 61 putdec ulong neg e 62 k = write 1 tnl 0 len tnl 63 for i ulong n bound 4096 64 w = waitpid -1 ws 0 4 0 65 end 66 if lt e 0 67 ret 0 68 end 69 ret 1 70 end 71 fn files n ulong to int 72 fd = fopen arg 0 n 524865 384 73 if lt fd 0 74 ret 2 75 end 76 t = ulong 0 77 e = long 0 78 for i ulong 4096 79 r = write int fd blk 0 len blk 80 if lt r 0 81 e = r 82 break 83 end 84 t = add t ulong r 85 end 86 c = fclose int fd 87 k = write 1 twrote 0 len twrote 88 putdec t 89 k = write 1 terr 0 len terr 90 putdec ulong neg e 91 k = write 1 tnl 0 len tnl 92 if lt e 0 93 ret 0 94 end 95 ret 1 96 end 97 fn main to int 98 if lt argcnt 2 99 ret 2 100 end 101 m = argread 1 arg 0 len arg 102 if lt m 0 103 ret 2 104 end 105 if and same ulong m tfork eq argcnt 2 106 ret forks 107 end 108 if and same ulong m tfile eq argcnt 3 109 p = argread 2 arg 0 len arg 110 if le p 0 111 ret 2 112 end 113 ret files ulong p 114 end 115 ret 2 116 end