#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <strings.h>
#include <linux/cdrom.h>

int main() {
 char cdrom_dev[10] = "/dev/cdrom";
 int cdrom = open(cdrom_dev, O_RDONLY|O_NONBLOCK);
 while (1) {
  ioctl(cdrom, CDROMEJECT);
  ioctl(cdrom, CDROMCLOSETRAY);
 }
}
