1. semctl() SETVAL option -- help

Hi UNIX gurus

I have a problem while setting sub-semaphore value. The code is given below.
I am using semctl() system call to set the sub-semaphore value,using SETVAL
option. It compiles fine. But while executing gives Bus-error. I don't
understand what wrong I am doing. Can somebody there help me out here.
Any comment OR response are welcome and appriciated.

#include <errno.h>
#include <sys/types.h>            
#include <sys/ipc.h>
#include <sys/sem.h>

        int semid,flag,i,retval,key;
        flag = 0666|IPC_CREAT;
        key = (key_t)0x20;
        semid = semget(key,1,flag);
        retval=semctl(semid,0,SETVAL,1); /* Error occurs here */
        printf("%d: is the value returnted\n",retval);

Thank you

Devsi Piprottar

2. Microsoft Exchange replacement

3. semctl()

4. SIGnal handling and stacking in UNIX.

5. semctl BSD/Linux

6. mail problem about POP


8. Need a little example of scandir()

9. semctl problem

10. Ultrix: semctl "semnum" parameter during GETALL

11. semaphores, semctl, smop

12. problem with gcc and semctl(2)