Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Bernie
Thu, 09 Apr 1992 21:10
(none)
Author: 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);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads