Unless I am missing some serious differences in Mac and linux in terms of C programming, I dont know why this would happen. Please take a look at the following piece of code fragment:
This function is part of a bigger programs that takes in user input and logs it into a file. As you might see, I am trying to get an write lock on the logfile as soon as it opens and release the lock before the file is closed. When I run it on linux (ubuntu hardy), the program runs without any problems. However, when I run it on my mac (Leopard), I get:
If someone could explain why this would be, it'd be helpful.
hi, I need to know how to lock a file. I used the following code, but after executing the program the file 'write.txt' remined empty, and I have no idea why.Maybe I'm not using the corresponding syntax for blocking a file. But I deleted then the blocking part and the problem persisted.
see to... (2 Replies)
I'm in the same boat as Barbus - same exercis (https://www.unix.com/shell-programming-scripting/43609-processes-users.html)
The following script works on a solaris server I have access to. It doesn't however, work on the companies Linux machine. Any idea what's up? I have very little shell... (0 Replies)
I have very simple client - server setup, where client connects, exchanges some messages with the server and then closes socket and exits. Everythink works OK, except when I am trying to change socket to be non-blocking AND the shell happens to be plain old Bourne. It runs no problem under ksh or... (3 Replies)
Hello,
I found this command works on Linux:
$ echo `uptime` | awk -F "load average: " '{ print $2 }'
1.60, 1.53, 1.46
but got error on Solaris:
$ echo `uptime` | awk -F "load average: " '{ print $2 }'
awk: syntax error near line 1
awk: bailing out near line 1
$ which awk... (2 Replies)
Hello
I have a Perl script that works on non-darwin Mac OS X environments and I think I have narrowed down the issue to a file locking problem.
In other linux environments, the flock struct is defined differently. I have adjusted this via the reference for Mac OS X fcntl(2) man page. The... (4 Replies)
Hi, I have a question.
I define a function using sed command:
replace()
{
searchterm=$1
replaceterm=$2
sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp'
mv $WORK'tempfile.tmp' $3
}
Then I call
replace 'test = 0' 'test = 1' $myfileThis code works well in... (1 Reply)
Hi, I have a question.
I define a function using sed command:
replace()
{
searchterm=$1
replaceterm=$2
sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp'
mv $WORK'tempfile.tmp' $3
}
Then I call
replace 'test = 0' 'test = 1' $myfile
This code... (1 Reply)
Good evening, friends
I'm learning with a book: Programming Linux by Kurt Wall (Prentice Hall)
The code below could run in two windows (./lockit /tmp/foo in both for example). There is not problem with the read block (first byte) but when one, apply the write block while in the other is... (1 Reply)
Hello,
I have a ksh script that uses code below. For some reason it works under linux but fails in unix. Any idea why?
if ]; then ...
Thanks (9 Replies)
Hello folks,
I pretend acquire this hardware:
1-Motherboard Asus Skt1151 - H110M-A/M.2 (https://www.asus.com/pt/Motherboards...cifications/);
2-Intel i5 6400 2.7Ghz QuadCore Skt1151;
or
2-Intel i5 6500 3.2Ghz QuadCore Skt1151;
3-Dimm 8GB DDR4 Kingston CL15 2133Mhz;
Obvious I pretend... (1 Reply)
Discussion started by: enodev
1 Replies
LEARN ABOUT LINUX
vop_advlock
VOP_ADVLOCK(9) BSD Kernel Developer's Manual VOP_ADVLOCK(9)NAME
VOP_ADVLOCK -- advisory record locking
SYNOPSIS
#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/fcntl.h>
#include <sys/lockf.h>
int
VOP_ADVLOCK(struct vnode *vp, caddr_t id, int op, struct flock *fl, int flags);
DESCRIPTION
The arguments are:
vp The vnode being manipulated.
id The id token which is changing the lock.
op The operation to perform (see fcntl(2)).
fl Description of the lock.
flags One of more of the following:
F_RDLCK Shared or read lock.
F_UNLCK Unlock.
F_WRLCK Exclusive or write lock.
F_WAIT Wait until lock is granted.
F_FLOCK Use flock(2) semantics for lock.
F_POSIX Use POSIX semantics for lock.
This entry point manipulates advisory record locks on the file. Most file systems delegate the work for this call to lf_advlock().
RETURN VALUES
Zero is returned on success, otherwise an error is returned.
SEE ALSO fcntl(2), flock(2), vnode(9)AUTHORS
This manual page was written by Doug Rabson.
BSD June 30, 1999 BSD