public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Meenakshi Pant <meenakshi.pant28@gmail.com>
To: cygwin@cygwin.com
Subject: SEMCTL fails with error 22
Date: Fri, 11 Mar 2016 10:19:00 -0000	[thread overview]
Message-ID: <CAAeFwS2mbvRMkqQLuSZoAyUHLgzzijLWvLOKoWSVXeFw25PcgQ@mail.gmail.com> (raw)

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

             reply	other threads:[~2016-03-11 10:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 10:19 Meenakshi Pant [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAeFwS2mbvRMkqQLuSZoAyUHLgzzijLWvLOKoWSVXeFw25PcgQ@mail.gmail.com \
    --to=meenakshi.pant28@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).