I get a segmentation fault with this code on fprintf:
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
int fd;
int main(int argc, char **argv) {
fd = posix_openpt(O_RDWR | O_NOCTTY);
fprintf(fd, "hello\n");
close(fd);
}
But it works fine with:
fprintf(stderr, "hello\n");
What is causing this?