Article View: gnu.gcc.bug
Article #351(none)
From: Bernie
Date: Thu, 09 Apr 1992 21:10
Date: Thu, 09 Apr 1992 21:10
39 lines
1483 bytes
1483 bytes
/*
* I can't get the following piece of code to work when I use
* gcc 1.40 under SunOS 4.1.1 on a SPARC 2 machine. I'm getting
* a core dump after calling the semctl() function. When I
* use the Sun C compiler, all is OK and I don't get a core dump.
*
* I'm using standard System V semaphores -- all I want to do
* is set the value of a semaphore to zero.
*
* If you could take a look at this problem and let me know
* what you find out, I'd greatly appreciate it.
*
* Thanks in advance -- Bernie Thuman (bht@roadnet.com).
*/
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#define SEM_KEY (key_t) 12345 /* Semaphore key default. */
main ()
{
int id; /* ID of semaphore. */
union semun semctl_arg; /* semctl() argument. */
key_t key = SEM_KEY; /* value of semaphore key. */
/* Get a semaphore: */
if ((id = semget (key, 1, 0666 | IPC_CREAT)) < 0) {
perror ("semget() failed");
exit (0);
}
/* Set the value of the semaphore to zero: */
semctl_arg.val = 0;
if (semctl (id, 0, SETVAL, semctl_arg) < 0) {
perror ("semctl() failed");
exit (1);
}
exit (0);
}
Technical Details
Message-ID:
<9204091710.aa00426@roadnet.roadnet.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!roadnet.COM!bhtShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!roadnet.COM!bht From: bht@roadnet.COM (Bernie) Subject: (none) Message-ID: <9204091710.aa00426@roadnet.roadnet.COM> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 9 Apr 1992 21:10:45 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 40