• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Shell program locking up CD Drive

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am writing a multi-cd spanning installer for a particular software in Linux (Redhat 4 or greater / Suse )

My Program is in Java. A Shell Script is used to fork the java process. I found out that when the Installer tries to go to the next disc when prompted so, by the installer, the eject command or the umount command is not able to eject / unmount the CD which is already there in the drive.

The eject / umount reports that the device is busy.

Now I tried to find out the process which is accessing the CD-ROM device and the output of command
fuser -m /cdrom0

gives me the PID of the shell process which was used to launch this Java process.

Please note that the Java Process has a separate PID. Also please note as soon as the user launches the shell command for the installer, I copy the files to the temporary directory and then cd to the temporary dir location and then fork the java process from there.

How can i solve this problem ? How can i make the mount of the second and subsequent CD Drives work without this issue ?

Thanks in advance,
Jiju Jacob
[ EJFH: UseTheForumNotEmail ]
[ July 17, 2008: Message edited by: Ernest Friedman-Hill ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure the Java program is closing all the files it opens for reading?

Are you sure neither the shell script nor the Java program has the CD as its current working directory?
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you may be running the java application from the drive - in which case it will be locked until the application terminates.

Using 'lsof' should give you a list of all open files from which you can grep for your cd drive.

- Ack, ignore - I had not read your post in enough detail.
[ July 17, 2008: Message edited by: Craig Taylor ]
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect that you are just executing the Java process within the shell itself (which would be why you are still seeing the shell's PID). If you no longer need that shell, then you could try exec to replace the shell process with the Java process.

man sh then search for exec. Personally I searched for exec[^u] so that I was able to skip all the instances of "executable".

Regards, Andrew
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic