?
Solved

File Locking on Solaris

Posted on 1999-01-29
4
Medium Priority
?
489 Views
Last Modified: 2013-12-05
Hi !

I am trying to use file locking under Solaris 2.51 on a Sun Ultra machine.  I can not get it to compile, I have included all the required header files.  The only thing that I am not sure of is if I am suppose to put some linking in my Makefile

My call to flock is :-

  FILE fp;
  .....
  flock(fp,LOCK_EX);

flock is shown as an undefined symbol.

Please could anybody help.

Marvin.
0
Comment
Question by:checkin
  • 2
4 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1258531
Do you have the source code for the flock() function? I didn't find it in my function listings...

-Viktor
--Ivanov
0
 

Accepted Solution

by:
mih earned 200 total points
ID: 1258532
Which C compiler are you using?

Are you actually having a compile problem or is it at the link stage?
- I guess it is a link problem - so, you might want to try adding -L/usr/ucb/lib -lucb (I think they are right, I don't have access to my Solaris machine today).

You may also want to consider using fcntl() rather than flock(), particularly if the file system can be accessed remotely (A lock applied with flock() is not visible from remote file system access such as NFS).

0
 

Author Comment

by:checkin
ID: 1258533
The compiler I use is gcc.  I tried linking the ucb file in, it compiled ad linked but just died when trying to run it but no core dump.
0
 

Expert Comment

by:mih
ID: 1258534
I'm a little confused by your program dying without a core-dump. What do you mean by dying? Did it hang? Did you get any error code at all?

Make sure you set your coredump size to be unlimited (use the following command):
limit coredumpsize unlimited

If you can give me a little more of your code, I might be able to help some more.
Have you got access to a debugger?

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question