2 * Use set/get/endgrent calls from two processes to iterate over the
3 * password database. This checks the multithreaded stuff works.
14 void dump_grent(char *id)
20 /* Open results file */
22 sprintf(fname, "/tmp/getgrent_r-%s.out-%d", id, getpid());
24 if ((fptr = fopen(fname, "w")) < 0) {
25 fprintf(stderr, "ERROR: could not open file %s: %s\n", fname,
30 /* Dump group database */
34 while((gr = getgrent()) != NULL) {
35 fprintf(fptr,"%s:%s:%d:%d\n", gr->gr_name, gr->gr_passwd,
41 /* Close results file */
46 int main(int argc, char **argv)
53 printf("ERROR: must specify output file identifier\n");
57 /* Fork child process */
59 if ((pid = fork()) == -1) {
60 printf("ERROR: unable to fork\n");
64 /* Handle test case */
82 printf("PASS: run getgrent_r.c\n");