#include #include #include #include #define CDDEVICE "/dev/cdrom" /* CDROM device */ int main(int argc,char **argv) { int cdrom; if ((cdrom = open(CDDEVICE,O_RDONLY | O_NONBLOCK)) < 0) { perror("open"); exit(1); } /* Use ioctl to send the CDROMEJECT command to the device */ if (ioctl(cdrom,CDROMEJECT,0)<0) { perror("ioctl"); exit(1); } close(cdrom); }