Hi friends,
I hope you guys are doing well. I am facing this problem, hope you can help me with it. I am trying to create a semaphore inside a structure. The idea is that I am creating a shared memory space between two processes. The reason for a semaphore is that I want some kind of synchronization between the two processes. I think you should see my code, it will become clear to you. I am also including the error that the compiler is giving me.
echo name the file that you want to read
read answer
if
then
echo you must enter a file name
fi
cat $answer
im trying to catch the error if user forget to enter the name of the file
anyone can help me ?
thanks:confused: (4 Replies)
Hi all
Is it possible to copy a structure of a directory only.
e.g.
I have a file with the following entries that is a result of a find :-
/dir1/dir2/file.dbf
/dir1/dir2/dir3/file1.dbf
/dir1/file.dbf
I want to copy these to a directory and keep the structure however starting at a new dir... (8 Replies)
Hi,
I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)
Hi,
Can anyone help me with the following case structure?
echo "Please enter the date for which you want the Report:\c"
read dat
d1=`echo $dat|cut -c7-8`
m1=`echo $dat|cut -c5-6`
y1=`echo $dat|cut -c1-4`
yr=`expr "$d1" - 1`
case "$yr" in
0)
MONTH=`expr "$m1" - 1`... (4 Replies)
Hello Groups
I am trying to find out ways of comparing a value from a 'c' structure to a value in another 'C' structure. the 'C' structure can be a List or liked list as it contains lot many records.
if we loop it in both the structures it is going to consume time.
I am looking for a simple... (3 Replies)
Hi...
I have a directory which has multiple directories and sub directories inside...
what command should i use to get a list of all these directories, without the filenames.... (2 Replies)
I need to use the below global structure defined in code1.c in another code2.c
struct memIOptrs
{
const char *name;
unsigned char *virtptr;
}MEM_IO_PTRS;
I have a header file for the project codes.h, how should the structure be declared here.
Also, what if the structure was... (1 Reply)
Discussion started by: dragonpoint
1 Replies
LEARN ABOUT FREEBSD
sem_wait
SEM_WAIT(3) BSD Library Functions Manual SEM_WAIT(3)NAME
sem_wait, sem_trywait -- decrement (lock) a semaphore
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <semaphore.h>
int
sem_wait(sem_t *sem);
int
sem_trywait(sem_t *sem);
DESCRIPTION
The sem_wait() function decrements (locks) the semaphore pointed to by sem, but blocks if the value of sem is zero, until the value is non-
zero and the value can be decremented.
The sem_trywait() function decrements (locks) the semaphore pointed to by sem only if the value is non-zero. Otherwise, the semaphore is not
decremented and an error is returned.
RETURN VALUES
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the
error.
ERRORS
The sem_wait() and sem_trywait() functions will fail if:
[EINVAL] The sem argument points to an invalid semaphore.
Additionally, sem_wait() will fail if:
[EINTR] A signal interrupted this function.
Additionally, sem_trywait() will fail if:
[EAGAIN] The semaphore value was zero, and thus could not be decremented.
SEE ALSO sem_getvalue(3), sem_post(3), sem_timedwait(3)STANDARDS
The sem_wait() and sem_trywait() functions conform to ISO/IEC 9945-1:1996 (``POSIX.1'').
BSD April 16, 2013 BSD