This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SEMCTL fails with error 22


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

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);

      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 );
      printf("Semaphore %d initialized.\n", KEY);


Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]