1*b30d1939SAndy Fiddaman# aso method feature tests 2*b30d1939SAndy Fiddaman 3*b30d1939SAndy Fiddamanaso fcntl note{ fcntl(F_SETLCK[W]) work }end link{ 4*b30d1939SAndy Fiddaman #include <sys/types.h> 5*b30d1939SAndy Fiddaman #include <unistd.h> 6*b30d1939SAndy Fiddaman #include <fcntl.h> 7*b30d1939SAndy Fiddaman 8*b30d1939SAndy Fiddaman int main() 9*b30d1939SAndy Fiddaman { 10*b30d1939SAndy Fiddaman struct flock lock; 11*b30d1939SAndy Fiddaman 12*b30d1939SAndy Fiddaman lock.l_type = F_WRLCK; 13*b30d1939SAndy Fiddaman lock.l_whence = SEEK_SET; 14*b30d1939SAndy Fiddaman lock.l_start = 0; 15*b30d1939SAndy Fiddaman lock.l_len = 1; 16*b30d1939SAndy Fiddaman return fcntl(1, F_SETLKW, &lock) < 0; 17*b30d1939SAndy Fiddaman } 18*b30d1939SAndy Fiddaman}end 19*b30d1939SAndy Fiddaman 20*b30d1939SAndy Fiddamanaso semaphore note{ semget semop semctl work }end link{ 21*b30d1939SAndy Fiddaman #include <sys/types.h> 22*b30d1939SAndy Fiddaman #include <sys/stat.h> 23*b30d1939SAndy Fiddaman #include <unistd.h> 24*b30d1939SAndy Fiddaman #include <fcntl.h> 25*b30d1939SAndy Fiddaman #include <sys/ipc.h> 26*b30d1939SAndy Fiddaman #include <sys/sem.h> 27*b30d1939SAndy Fiddaman 28*b30d1939SAndy Fiddaman int main() 29*b30d1939SAndy Fiddaman { 30*b30d1939SAndy Fiddaman int id; 31*b30d1939SAndy Fiddaman struct sembuf sem; 32*b30d1939SAndy Fiddaman 33*b30d1939SAndy Fiddaman if ((id = semget(IPC_PRIVATE, 16, IPC_CREAT|IPC_EXCL|S_IRUSR|S_IWUSR)) < 0) 34*b30d1939SAndy Fiddaman return 1; 35*b30d1939SAndy Fiddaman sem.sem_num = 0; 36*b30d1939SAndy Fiddaman sem.sem_op = 1; 37*b30d1939SAndy Fiddaman sem.sem_flg = 0; 38*b30d1939SAndy Fiddaman if (semop(id, &sem, 1) < 0) 39*b30d1939SAndy Fiddaman return 1; 40*b30d1939SAndy Fiddaman if (semctl(id, 0, IPC_RMID) < 0) 41*b30d1939SAndy Fiddaman return 1; 42*b30d1939SAndy Fiddaman return 0; 43*b30d1939SAndy Fiddaman } 44*b30d1939SAndy Fiddaman}end 45