Date: Mon, 13 Jan 2003 19:50:22 -0600 From: Fox <foxbsd@gristle.to> To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: freebsd-newbies@FreeBSD.ORG Subject: Re: detecting open cd drive Message-ID: <5.0.2.1.0.20030113194731.026c8690@pop-server.austin.rr.com> In-Reply-To: <20030113234819.GA3695@gothmog.gr> References: <5.0.2.1.0.20030113091738.02802130@pop-server.austin.rr.com> <20030110031616.359a7dcc.one-@madridwireless.net> <5.0.2.1.0.20030113091738.02802130@pop-server.austin.rr.com>
next in thread | previous in thread | raw e-mail | index | archive | help
At 01:48 AM 1/14/03 +0200, Giorgos Keramidas wrote: >On 2003-01-13 09:20, foxbsd@gristle.to (Fox) wrote: > > Is there a way to detect that the cdrom drive has been closed from > > userland. I want to launch a script triggered by the cdrom drive > > tray closing. > > > > I am using FreeBSD 4.7 > >You could probably poll using ioctl(fd, CDIOREADTOCHEADER, ...) but >this is something I haven't tested :-/ Thanks that worked out very well, and here is the code: int fd = 0; fd = open("/dev/acd0c", O_RDONLY); while(1) { success = ioctl(fd, CDIOREADTOCHEADER, &ith); if (success != -1) { close(fd); execl("/home/user/test.py", 0); } else { close (fd); sleep(2); // try again. fd = open("/dev/acd0c", O_RDONLY); } } >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-newbies" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-newbies" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5.0.2.1.0.20030113194731.026c8690>