eric@snark.UUCP (Eric S. Raymond) (12/01/87)
Several months ago I posted 'semex', an exerciser for the System V semaphore primitives useful for learning their usage quirks and using the facilities from shellscripts. These changes fix minor bugs reported by Guy Harris (guy@sun) and Esmond Pitt (ejp@ausmelb.oz.au) -- my thanks to these two for their feedback and apologies for taking so long to post the corrections. They also cause the semex.c sources to lint clean. 165c165 < extern char *strchr(), *strcat(); --- > extern char *strchr(), *strcat(), *ctime(); 218c218 < static void sigabort(sig) --- > static int sigabort(sig) 222c222 < (void) fprintf("Received signal %d\n", sig); --- > (void) printf("Received signal %d\n", sig); 260c260 < (void) fprintf(stdout, --- > (void) printf( 274c274 < (void) fprintf(stdout,"semop in process %d failed: %s\n", --- > (void) printf("semop in process %d failed: %s\n", 277c277 < (void) fprintf(stdout, --- > (void) printf( 302c302 < (void) fprintf(stdout, "The exerciser process pid is %d\n", parent); --- > (void) printf( "The exerciser process pid is %d\n", parent); 303a304 > 339a341 > #ifndef lint 341c343,344 < (void) printf("Semaphore id %d selected\n", semid); --- > #endif /* lint */ > (void) printf(cmdline, "Semaphore id %d selected\n", semid); 344a348 > #ifndef lint 346c350,351 < (void) printf("Semaphore index %d selected\n", semnum); --- > #endif /* lint */ > (void) printf(cmdline, "Semaphore index %d selected\n", semnum); 372c377 < (void)fprintf(stdout,"Spawning child with pid = %d\n",rv); --- > (void) printf("Spawning child with pid = %d\n",rv); 417c422,426 < int semval = 0; --- > union { > int val; > struct semid_ds *buf; > unsigned short *array; > } semval; 419c428 < (void) sscanf(cmdline, "s %d", &semval); --- > semval.val = 0; 420a430,431 > (void) sscanf(cmdline, "s %d", &semval.val); > 504c515 < return; --- > return(0); 511,523c522,534 < printf("c(reate) key nsems [ce] perms -- create a semaphore group\n"); < printf("f(ind) semid -- select a semaphore group by id\n"); < printf("i(ndex) semnum -- select a semaphore index\n"); < printf("d(o) op [un] -- do a semaphore operation\n"); < printf("v(alue) semid semnum -- query a semaphore's semval\n"); < printf("p(id) semid semnum -- query a semaphore's sempid\n"); < printf("n(cnt) semid semnum -- query a semaphore's semncnt\n"); < printf("z(cnt) semid semnum -- query a semaphore's semzcnt\n"); < printf("m(mask) semid uid gid mode -- query/set a semaphore's mode\n"); < printf("r(emove) semid -- remove a semaphore group\n"); < printf("s(et) semval -- set the value of a semaphore\n"); < printf("l(ist) -- run ipcs -sbopt\n"); < printf("x(it) -- exit\n\n"); --- > (void)printf("c(reate) key nsems [ce] perms -- create a semaphore group\n"); > (void)printf("f(ind) semid -- selectsemaphore group by id\n"); > (void)printf("i(ndex) semnum -- select a semaphore index\n"); > (void)printf("d(o) op [un] -- do a semaphore operation\n"); > (void)printf("v(alue) semid semnum -- query a semaphore's semval\n"); > (void)printf("p(id) semid semnum -- query a semaphore's sempid\n"); > (void)printf("n(cnt) semid semnum -- query a semaphore's semncnt\n"); > (void)printf("z(cnt) semid semnum -- query a semaphore's semzcnt\n"); > (void)printf("m(mask) semid uid gid mode -- query/set semaphore's mode\n"); > (void)printf("r(emove) semid -- remove a semaphore group\n"); > (void)printf("s(et) semval -- set given semaphore's value\n"); > (void)printf("l(ist) -- run ipcs -sbopt\n"); > (void)printf("x(it) -- exit\n\n"); 525,526c536,537 < printf("! cmd -- execute a shell command\n"); < printf("? -- print this help message\n\n"); --- > (void)printf("! cmd -- execute a shell command\n"); > (void)printf("? -- print this help message\n\n"); 535a547 > return(0); You may, alternatively, email to me (eric@snark) for full sources if desired. (Rich $alz: do you want to repost the corrected version?) -- Eric S. Raymond UUCP: {{seismo,ihnp4,rutgers}!cbmvax,sdcrdcf!burdvax,vu-vlsi}!snark!eric Post: 22 South Warren Avenue, Malvern, PA 19355 Phone: (215)-296-5718