This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
cygwin 1.3.10 semctl fails, but does not set errno
- From: Michael Potter <pottmi at lidp dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 3 Jun 2002 11:25:35 -0500 (CDT)
- Subject: cygwin 1.3.10 semctl fails, but does not set errno
- Organization: Life Insurance Data Processing Incorporated
- Phone: +1 630 829 7015
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ipc.h>
#include <sys/shm.h>
/* ----------------------------------------------------------------
** This program demostrates that semctl returns -1 (an error) but
** does not set errno (or at least sets it to 0).
**
** Compile this test program like this:
** gcc -o semctltest semctltest.c -lcygipc
**
** The problem is demostrated when you get this output:
** -> ./shmctltest
** shmctl failed with 0
**
** If you get:
** -> ./shmctltest
** shmget failed with 17
** Then you need to use ipcrm to remove the shared memory.
*/
int main(int argc, char *argv[])
{
int shmid;
int SaveErrno;
struct shmid_ds shmid_ds;
if ((shmid = shmget(508, 1024*1024, 0666|IPC_CREAT|IPC_EXCL)) == -1)
{
SaveErrno = errno;
printf("shmget failed with %d\n", SaveErrno);
exit(1);
}
shmid_ds.shm_perm.uid = getuid();
shmid_ds.shm_perm.gid = getgid();
shmid_ds.shm_perm.mode = 0666;
if (shmctl(shmid, IPC_SET, &shmid_ds) == -1)
{
SaveErrno = errno;
printf("shmctl failed with %d\n", SaveErrno);
exit(1);
}
exit(0);
}
--
Michael Potter
LIDP Consulting Inc.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/