Prior to this fix, the compare-outputs test suite was showing a strange
behavior, the tests always stopped between tests 6-8 and had a stack track
similar to each other.
```
Test 8/68 compare-output multiple files with private function (ReleaseSmall)...OK
/usr/home/mgxm/dev/zig/zig-cache/source.zig:7:2: error: invalid token: '&'
}&(getStdOut() catch unreachable).outStream().stream;
^
The following command exited with error code 1:
```
With the wrong O_* flags, the source code was being written in append mode which
resulted in an invalid file
```zig
use @import("foo.zig");
use @import("bar.zig");
pub fn main() void {
foo_function();
bar_function();
}&(getStdOut() catch unreachable).outStream().stream;
stdout.print("OK 2\n") catch unreachable;
}
fn privateFunction() void {
printText();
}
```
FreeBSD doesn't mount procfs as default on the base system, so we can't
depend on it to get the current path, In this case, we use sysctl(3) to
retrieves the system information and get the same information.
- CTL_KERN: High kernel limits
- KERN_PROC: Return selected information about specific running
processes.
- KERN_PROC_PATHNAME: The path of the process
- Process ID: a process ID of -1 implies the current process.
The system call getrandom(2) just landed on FreeBSD 12, so if we want to
support some earlier version or at least FreeBSD 11, we can't depend on
the system call.