LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to release all locks that the current terminal session is holding? (https://www.linuxquestions.org/questions/linux-general-1/how-to-release-all-locks-that-the-current-terminal-session-is-holding-4175475313/)

Lop3 08-30-2013 09:13 AM

How to release all locks that the current terminal session is holding?
 
Question:
How can I make the current terminal window give up all its file & dir locks so I can umount?

Setup:
I've written a PHP CLI script to mount or dismount my TC volumes.
I run the script from the terminal and wait a few seconds for it to finish.
(Just to be clear: The script does not keep running and it does not access anything inside the mounted volume. The problem occurs whether I use the PHP script or type the commands manually. Its just to automate the process of mounting and dismounting volumes.)

Steps to reproduce problem:
(I will just paste the relevant lines so you can see what commands I'm using, there are various validations before and after each command, so don't worry about the variable names)
* Mount a truecrypt volume with tcplay inside a terminal window using these commands
Quote:

sudo mkdir $mountpath
sudo losetup $firstloop $tcpath/$tcfile
sudo tcplay -m $tcmapname -d $loop
* Use the TC volume from other programs, close them all when done. (might be optional)
* Fiddle around with files and dirs inside the mounted volume.
* cd / (so I'm not *in* the mounted volume when I try umount)
* Try umount the TC volume from the same terminal window that I mounted it with.
it complains that the TC volume is in use.
Quote:

sudo umount $mountpath
Workaround:
* CLOSE the terminal window then open a NEW terminal window and give the umount command.

Interesting:
* In the past I tried some command to kill locking processes on that volume, it was really funny. it closed the terminal I entered the command in.
* If I just mount from terminal x, use other terminals or programs, then dismount from terminal x it dismounts cleanly without any error.

First prize:
Some command that makes the current terminal session give up any locks it's holding on any files/dirs. That would be awesome.

OS:
Linux Mint 15 x64 (based on Ubuntu 13.04), Mate 1.6, Main shell: zsh, scripts: PHP or Bash

sgosnell 08-30-2013 01:42 PM

Have you tried "rm *.lock"? I don't really know how Truecrypt locks things, but the usual way to lock a file is to use a zero-byte file named "something.lock" where "something" is a name the program that wants to lock the file makes up, often the name of the program. That file is usually in the working directory of the program.

Lop3 09-11-2013 10:23 AM

I don't think truecrypt makes .lock files.
For some reason I haven't had an issue lately.
I'll mark this as solved for now.

Thanks


All times are GMT -5. The time now is 06:15 AM.