1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
namespace;
include rt;
extern int fcntl(int fd, int command);
int descriptors() { int count = 0; for (int fd = 0; fd < 256; fd++) if (fcntl(fd, 1) >= 0) count++; return count; }
unchecked fn main() {
int before = descriptors(), i = 0, closed = 0;
while (i < 24) {
int fd = 0;
let context = rt.syscall(51, fn() { int value = 1; rt.syscall(44, fd, &value, 1); return 0; } as word, &fd, 0);
int result; rt.syscall(45, fd, &result, 1); rt.syscall(52, context, 0, 0);
closed += rt.syscall(44, fd, &result, 1) == -1; i++;
}
rt.put_n(descriptors() == before); rt.put_c(' '); rt.put_n(closed); rt.put_c(' ');
rt.put_n(rt.syscall(55, 0, 0, 0)); rt.put_c(' '); rt.put_n(rt.syscall(55, 1, 0, 0)); rt.put_c(' '); rt.put_n(rt.syscall(55, 2, 0, 0)); rt.put_c(10); return 0;
}
|