473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to check the lock status?

How to obtain the lock status of a file held by other process?
If I read the file that is locked by other process, the read would
return -1.
If the file is locked by other process, how to put the read to sleep for a
second and try again after a period of time?
Thanx
Nov 14 '05 #1
2 2791
"Janice" <no@mail.com> writes:
How to obtain the lock status of a file held by other process?
If I read the file that is locked by other process, the read would
return -1.
If the file is locked by other process, how to put the read to sleep for a
second and try again after a period of time?


There's no way to do this in standard C. Try a newsgroup that's
specific to your system (comp.unix.programmer,
comp.os.ms-windows.programmer.win32, or whatever).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #2
On Sat, 20 Nov 2004 19:24:50 +0800, "Janice" <no@mail.com> wrote:
How to obtain the lock status of a file held by other process?
You need to ask the newsgroup of the operating system you are asking about.
It can be any of the following (as stated in the "Welcome to comp.lang.c!"
posting):

:Operating Systems
:
: news:comp.os.msdos.programmer DOS, BIOS, Memory Models,
: interrupts, screen handling,
: hardware
: news:comp.os.ms-windows.programmer.misc MS/Windows: Mice, DLLs, hardware
: news:comp.os.ms-windows.programmer.win32 MS 32-bit API
: news:comp.os.os2.programmer.misc OS/2 Programming
: news:comp.sys.mac.programmer.misc Macintosh Programming
: news:comp.unix.programmer General Unix: processes, pipes,
: POSIX, curses, sockets
: news:comp.unix.[vendor] Various Unix vendors
: news:comp.os.linux.development.apps Linux application programming
If I read the file that is locked by other process, the read would
return -1.


You should refer it to EOF, not -1. While not critical, it does help
provide the context at which a '-1' will appear. In addition, you really
should provide the name of the function you are using to read - for
example, if you are using the fgetc() function or something else.
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jake | last post by:
I have a deadlock situation, part of the problem looks like this; spid ecid dbid ObjId IndId Type Resource Mode Status ------ ------ ------ ----------- ------ ----...
18
by: Robert | last post by:
Hi! I was wondering if the was any way to determine the state of the caps lock key, on or off. Of course I can capture the key events and see whether the caps lock is pressed, but that does not...
3
by: xixi | last post by:
can someone explain to me what is internal p lock, internal s lock, internal v lock? when i have IS lock or IX lock , i always have these internal locks together for the application handle ...
0
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX 5.2.0.0. We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
16
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
3
by: shorti | last post by:
Hello all, I am running with DB2 UDB V8 on AIX. I am trying to track down what appears to be a lock issue. I turned EVENT MONITOR on with all the options. It doesnt give me the detailed...
45
by: Chris Forone | last post by:
hello group, is there a chance for other functions to get the lock if i have following loop: while (running) { Lock local(mutex); }
5
by: wassimdaccache | last post by:
Hello Does anyone know how can I get the status of Caps Lock; Num Loc;k Srcoll lock? using access 2007. Regards,
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.