When I call semctl(), my program crashes. It works fine elsewhere.



The fourth argument to semctl() is a "union semun" that you need to
define yourself. That your programs works on other systems is
sheer luck. The argument passing convention on SPARC/V8 cause your
luck to run out. Instead of passing the contents of small structs
and unions in registers, a copy of the struct/union is made on the
stack and a pointer to that struct is passed.


In short, on SPARC, passing a union containing an integer and just
an integer, both by value, is not the same thing. On other systems
it sometimes is.


Wrong, but it may work on other systems:



semctl(sem_fd, 0, SETVAL, 1);


Right:



union semun {
int val;
struct semid_ds *buf;
ushort *array;
} arg;

arg.val = 1;

semctl(sem_fd, 0, SETVAL, arg);





UNIXguide.net
English to Visayan Cebuano Dictionary
Suggest a Site
Visayan Cebuano to English Dictionary