From: ahoward@... (ara howard) Date: 2002-01-24T07:55:08+09:00 Subject: Re: SysV::IPC, core dump heres a fix if anyone is interested > sysvipc must use an 'union senum' rather than NUM2INT(v_value) in the call > to semctl(2) > > p.s. : msgbuf is defined in /usr/include/sys/msgbuf.h and it's different > from the struct msgbuf defined in sysvipc.c > static VALUE rb_sem_set_all (obj, ary) VALUE obj, ary; { struct ipcid_ds *semid; /* unsigned short int *array; */ union semun *arg; int i, nsems; semid = get_ipcid_and_stat (obj); nsems = semid->semstat.sem_nsems; if (RARRAY(ary)->len != nsems) rb_raise (cError, "doesn't match with semnum"); /* array = xcalloc (nsems, sizeof (unsigned short int)); */ arg = xcalloc (nsems, sizeof (union semun)); for (i = 0; i < nsems; i++) /* array[i] = NUM2INT (RARRAY(ary)->ptr[i]); */ (arg+i)->val = NUM2INT (RARRAY(ary)->ptr[i]); /* semctl (semid->id, 0, SETALL, array); */ semctl (semid->id, 0, SETALL, arg); return obj; } static VALUE rb_sem_set_value (obj, v_pos, v_value) VALUE obj, v_pos, v_value; { struct ipcid_ds *semid; int pos; union semun arg; semid = get_ipcid_and_stat (obj); pos = NUM2INT (v_pos); Check_Valid_Semnum (pos, semid); arg.val = NUM2INT (v_value); /* if (semctl (semid->id, pos, SETVAL, NUM2INT (v_value)) == -1){ */ if (semctl (semid->id, pos, SETVAL, arg) == -1) rb_sys_fail ("semctl(2)"); return obj; } > > Guy Decoux SOURCE for rb_sem_set_val and rb_sem_set_all follows