Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-Id: <200206031625.LAA876434@lidp.com> Subject: cygwin 1.3.10 semctl fails, but does not set errno To: cygwin AT cygwin DOT com Date: Mon, 3 Jun 2002 11:25:35 -0500 (CDT) From: Michael Potter Organization: Life Insurance Data Processing Incorporated Phone: +1 630 829 7015 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII #include #include #include #include #include /* ---------------------------------------------------------------- ** 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/