Sponsored Content
Full Discussion: Open function of sys/stat.h
Top Forums Programming Open function of sys/stat.h Post 302411966 by cyler on Saturday 10th of April 2010 11:55:03 AM
Old 04-10-2010
Open function of sys/stat.h

If a process already has the entire file locked for read and write using newstruct.l_type = F_WRLCK; what would happen if another process would try to open it in read only mode using open(filename, O_RDONLY); ?

I want to check if the file exists and I want it to work even if another process has it locked. (I'm not sure what open would return if the file is already locked by another process...)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

function to test if file is open

I need to write a function that will work in sh/ksh shell that will test to see if a file has already been opened for writting by another user has anyone written something like this? (3 Replies)
Discussion started by: johnsonbryce
3 Replies

2. Programming

Hi errno in sys/stat.h

How should I use errno in a c program and what info does it have . I am working with directories and files. So can any one tell me How to access errno?I am using the stat() function on \etc directory and I am alble to access only the half of the directories.I am not able to access other half and... (6 Replies)
Discussion started by: vijlak
6 Replies

3. Programming

Q with stat()

From reading various articles on the net, I know stat() is used on files to get things like permissions, sizes etc... As a folder is a special type of file in Unix, I assumed that stat() could work on it as well as any general file. However, from running my program, perror() reported that the... (3 Replies)
Discussion started by: JamesGoh
3 Replies

4. UNIX and Linux Applications

Sybase help: Open client, bcp function

To begin: I use Linux The Problem: I need bcp functionality for scripts. Perl modules, such as Sybase:xfer, require ctlib which comes with Sybase Open Client. Talking with Sybase sales reps is an exercise in futility and hate. They know absolutely nothing about their own products and will... (0 Replies)
Discussion started by: Bubnoff
0 Replies

5. Programming

could not open source file "sys/elf_386.h"

Hello All, i am porting my application from SunSolaris to Linux (RHEL4). When i compile my c/c++ code i am getting the following errors. 1. catastrophic error: could not open source file "sys/elf_386.h" #include <sys/elf_386.h> 2. catastrophic error: could not open source file... (2 Replies)
Discussion started by: tsaravanan
2 Replies

6. Shell Programming and Scripting

Help !! perl open function

Help Please perl Gurus, I am trying to add ungrouped passengers in a group and I creating a script however it fails on first step only I tried all the options it returns following error. syntax error at junki line 4, near "open " Execution of junki aborted due to compilation errors. ... (2 Replies)
Discussion started by: dynamax
2 Replies

7. Shell Programming and Scripting

Stat value changes

Die to what all operations, the "Modify" and "Change" values of stat output changes for a file. I found, during editing a file, Change and Modify alters. When chmod'ing Change alters, while Modify doesnot alters. Is there more situations where these changes? (1 Reply)
Discussion started by: anil510
1 Replies

8. Programming

Function open() sets errno

I am opening a text file using open() system call in O_RDONLY mode. open() returns me a valid handler but also sets errno to 13 i.e. EACCES(Permission denied). Question is when open() is returning a valid handler then why does it sets the errno? Should not errno be set only in case of error... (10 Replies)
Discussion started by: rupeshkp728
10 Replies

9. Shell Programming and Scripting

Open file function

Hello all, just a quick little part of code i'm writing to check if the file i'm writing too in my automatic process is not being written too manually. #!/bin/bash FUSER=$(/sbin/fuser -s /toto.tmp >/dev/null 2>&1) LSOF=$(/usr/sbin/lsof | grep -q "toto.tmp") PGREP=$(pgrep -f "toto.tmp" >... (6 Replies)
Discussion started by: maverick72
6 Replies

10. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies
msem_lock(2)							System Calls Manual						      msem_lock(2)

NAME
msem_lock() - lock a semaphore SYNOPSIS
DESCRIPTION
attempts to lock a binary semaphore. sem points to an structure which specifies the semaphore to be locked. If the semaphore is not currently locked, it becomes locked and the function returns successfully. If the semaphore is currently locked, and condition is then the function returns with an error. If the semaphore is currently locked and condition is zero, the function does not return until either the calling process is able to successfully lock the semaphore, or an error condition occurs. All calls to and by multiple processes sharing a common structure behave as if the calls were serialized. If the structure contains any value not resulting from a call to followed by a (possibly empty) sequence of calls to and the results are undefined. The address of an uniquely identifies the semaphore. If the structure contains any value copied from an structure at a differ- ent address, the result is undefined. IMPLEMENTATION NOTES
If blocked on a locked semaphore, suspends the calling process at a priority such that the process can be interrupted by a signal. The system attempts to ignore or recover from invalid values written to the structure, but this is not guaranteed for all cases. successfully acquires a semaphore that is locked by a process that has exited. RETURN VALUE
returns one of the following values: Success. Failure. is set to indicate the error. ERRORS
sets to one of the following values if the corresponding condition is encountered. was specified and the semaphore was already locked. sem points to an structure that has been removed, or condition is invalid. was interrupted by a signal that was caught. The semaphore is currently locked, condition is zero, and waiting to lock the semaphore would create a deadlock. sem is not a properly aligned address or is otherwise an invalid pointer. AUTHOR
was developed by HP and OSF. SEE ALSO
msem_init(2), msem_remove(2), msem_unlock(2), mman(5). STANDARDS CONFORMANCE
msem_lock(2)
All times are GMT -4. The time now is 03:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy