public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* SEMCTL fails with error 22
@ 2016-03-11 10:19 Meenakshi Pant
  2016-03-11 10:38 ` Achim Gratz
  2016-03-11 10:53 ` Meenakshi Pant
  0 siblings, 2 replies; 8+ messages in thread
From: Meenakshi Pant @ 2016-03-11 10:19 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-17 11:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11 10:19 SEMCTL fails with error 22 Meenakshi Pant
2016-03-11 10:38 ` Achim Gratz
2016-03-11 10:53 ` Meenakshi Pant
2016-03-11 11:41   ` Marco Atzeri
2016-03-11 11:50     ` Meenakshi Pant
2016-03-11 12:16       ` Marco Atzeri
2016-03-17 11:18         ` Meenakshi Pant
2016-03-17 11:32           ` Marco Atzeri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).