Given that a simple program, as following:
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv)
{
int fd = -1;
if (access("/dev/tty", F_OK) == 0)
{
fd = open("/dev/tty", O_RDWR);
if (fd == -1)
perror("open() :");
}
return 0;
}
compile and make it as init (the frist process invoked by kernel), then reboot, but it would get the result:
open() :No such device or address
How to explain this ?