This is the mail archive of the
cygwin
mailing list for the Cygwin project.
SEMCTL fails with error 22
- From: Meenakshi Pant <meenakshi dot pant28 at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 11 Mar 2016 15:49:04 +0530
- Subject: SEMCTL fails with error 22
- Authentication-results: sourceware.org; auth=none
Hi,
My program creates a semaphore, but moving further the SEMCTL function
is failing with error 22 with the latest CYGWIN 2.4. The cygserver is
up.
Below is the simplified code as a test case.It fails with the same
error as my original program.
/* semtest.c - program to test semaphore */
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
extern int errno;
#define KEY (1492)
void main()
{
int id;
printf("\n Semaphore Test");
union semun {
int val;
struct semid_ds *buf;
ushort * array;
} argument;
argument.val = 0;
id = semget(KEY, 1, 0666 | IPC_CREAT);
if(id < 0)
{
printf("\n Unable to obtain semaphore %d ", errno);
exit(0);
}
printf("\n Semaphore created successfully %d ", id);
printf("\n Value before errno = %d", errno );
errno = 0;
if( semctl(id, 0, SETVAL, argument) < 0)
{
printf("\nCannot set semaphore value.errno = %d", errno );
}
else
{
printf("Semaphore %d initialized.\n", KEY);
}
}
Thanks
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple