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


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


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