Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > General > Linux, Mac OS X, & Co

Thread Tools Search this Thread Display Modes
Old 17th February 2014, 05:12   #1  |  Link
Registered User
beandog's Avatar
Join Date: Jun 2009
Location: /usa/utah/slc
Posts: 18
Waiting for DVD drive to become ready (small C program)

tl;dr - closing a tray doesn't mean it's ready to access, this can query the device and return proper status; useful for scripting


Long(er) version:

Okay, so, I'm a total noob at C, but I wrote a small program that polls a DVD drive to query its status.

I use my own DVD ripping scripts, and what they do is wait for the tray to be closed and have a DVD put in there.

Even though a tray can be closed, it's not necessarily ready to be accessed because the drive is still loading. Having that non-ready status breaks scripts that want to run something immediately.

One work-around is to just close the tray and wait a few seconds (do not like). So this little C program will query the drive status and return whether it is "ready" to access or not.

This avoids issues like this:

$ eject -t /dev/dvd # closes tray, drive begins polling
$ lsdvd /dev/dvd # barfs because tray is still polling

Anyway, I have justification / reasoning / documentation here on this page: http://dvds.beandog.org/doku.php/dvd_drive_status

This has fixed race conditions in my shell scripts that I've had for years, so it makes me very happy.

I hope this helps someone.
If it ain't broke, tweak it.
beandog is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 04:29.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.