Friday, July 5, 2019

This just gets worse and worse

More macos strangeness.
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char** argv) {
    int pid = fork();

    if (pid == 0) {
        printf("child, errno: %d\n", errno);
        exit(0);
    } else {
        printf("parent, errno: %d\n", errno);
        exit(0);
    }
}

And here's the output under macos.
$ ./a.out 
parent, errno: 0
child, errno: 22
The fork man page doesn't even list "Invalid argument" as a possible errno value...