2 * tst-syslogd.c - tests concurrent threads calling syslog
4 * build with: gcc -Wall tst-syslogd.c -lpthread
12 void *log_func(void *arg)
17 openlog(NULL, LOG_PERROR | LOG_PID, LOG_USER);
18 for (i = 0; i < 10; i++) {
19 syslog(LOG_DEBUG, "thread %i iter %i\n", thrid, i);
20 sleep(thrid); /* this mixes things up a bit */
27 int main(int argc, char **argv)
29 pthread_t thr1, thr2, thr3;
34 pthread_create(&thr1, NULL, log_func, (void *)id1);
35 pthread_create(&thr2, NULL, log_func, (void *)id2);
36 pthread_create(&thr3, NULL, log_func, (void *)id3);
38 pthread_join(thr1, NULL);
39 pthread_join(thr2, NULL);
40 pthread_join(thr3, NULL);