Click to See Complete Forum and Search --> : Locking file for a specified time (PERL)


just4spam
12-11-2003, 01:05 AM
I am working in a network enviroment and as such I have to be on the lookout for 'raised' conditions when writing code.

I want to open a file and present the user with some options and but only for about 30 seconds. The user prompt should die after this time because of inactivity.

I opened the file like this:

sysopen (Q, "\/file1\/part1\/devel\/test\/file.txt", O_RDWR) or print "Cannot open queue file\n";
flock (Q, LOCK_EX) or die "Can't get exclusive lock on queue file\n";

#do some processing
#prompt the user

print "Enter the job id you would like to remove from queue <ENTER> to cancel: ";
chomp ($itemToRemove = <STDIN>);

## I would like this prompt to be available to the user for only say 30 seconds after that it should terminate with a warning. Using sleep is not good enough.

Any thoughts

OmarSerenity
12-11-2003, 05:17 AM
http://www.pti.co.il/talks/Fundamentals/loginpl.html

just4spam
12-11-2003, 06:27 PM
Thank you, preciselt what I was looking for.

Just