sim@mdtf05.fnal.gov (James Sim) (06/28/91)
When I call semctl as follows under SunOS version 4.1, I get a segmentation fault. When I use the same code under Concurrent RTU, the code works fine. semctl(semid, semnum, GETVAL, 0); When the third argument is GETVAL, semctl is not using the fourth argument, if I read the man page correctly. I managed to get the code to work by changing the code as follows: struct sembuf sem_oper; semctl(semid, semnum, GETVAL, sem_oper); where sem_oper is an automatic variable, which has not been assigned any values prior to calling semctl. I don't see why this should work, since the contents of the automatic variable, sem_oper are indeterminate. I also tried semctl(semid, semnum, GETVAL, 1); thinking that semctl is expecting a non-zero fourth argument, although why it should expect ANYTHING for a fourth argument when the third argument is GETVAL I don't know. The man page for semctl does not mention the use of the fourth argument when the third argument is GETVAL, while it specifically outlines the use of the fourth argument for certain other values of the third argument. From this I inferred that semctl does not use the fourth argument when the third argument is GETVAL. So why am I getting a segmentation fault, and what is semctl really expecting for the fourth argument?