Results 26 comments of Vladimir Vrzić

Looks like a wrapper around `fwrite(3)` is needed. I tried a trivial shim: ``` size_t __unix_fwrite(const void * __restrict ptr, size_t size, size_t nmemb, FILE * __restrict stream) { return...

My guess here is that System V `struct FILE` binary layout is different from the one on BSD, and that we need to convert it, but I'm not yet sure...

Found [SVR4 source code on archive org](https://archive.org/details/ATTUNIXSystemVRelease4Version2).

@taviso Spot on, intercepting `write` instead of `fwrite` worked like a charm, thank you! FreeBSD port now seems to work 🎉 Since the undefine/redefine lists might differ between platforms, we'll...

The bug is upstream, in the binutils Makefile. Shell scripts used to configure sub-components use unqoted variables. Example: ``` .PHONY: configure-zlib maybe-configure-zlib maybe-configure-zlib: maybe-configure-zlib: configure-zlib configure-zlib: @r=`${PWD_COMMAND}`; export r; \...

Passing a pointer to heap memory to `ioctl` instead works around the problem: ``` void __attribute__((constructor)) init_terminal_settings() { // Make a backup of the terminal state to restore to later....

Although it passes the workaround, it proceeds to segfault here: ``` Program received signal SIGSEGV, Segmentation fault. 0x0804adb8 in ?? () (gdb) bt #0 0x0804adb8 in ?? () #1 0x0804a53b...

After rebuilding the symbol undefine list for OpenBSD (using the Linux list as the starting point), the "Bad address" `ioctl` issue is gone. I reverted the workaround. Program still segfaults...

Still, this is an anti-pattern very commonly seen in shell scripts and snippets, and it's worth pointing it out, for educational purposes. There are 3 problems with it: 1. Most...

Alternatively, `grep | cut` can be used instead of `awk`, with GNU tools this could reduce memory usage by ~2 megabytes (with 1 additional process, and similar execution time): ```...