Is there a way to detect if a CD is inserted in C on Linux?
I tried it with an SIGIO Signal:
fd = open("/dev/cdrom", O_RDWR | O_NONBLOCK );
struct sigaction saio;
saio.sa_handler = signal_handler_IO;
saio.sa_flags = 0;
saio.sa_restorer = NULL;
sigaction(SIGIO,&saio,NULL);
fcntl(fd, F_SETFL, FNDELAY);
fcntl(fd, F_SETOWN, getpid());
fcntl(fd, F_SETFL, O_ASYNC );
But the function "signal_handler_IO" is never called.
Is there a possibility doing it this way?