For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > July 2007 > Does calling wait() poll?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Does calling wait() poll?
K-mart Cashier

2007-07-13, 10:05 pm

Say I have a program that calls this function every 2 seconds

static int
tel(char *user, char *tty, const char *what)
{
pid_t cpid, wpid;
int stats;

cpid = fork();
if (cpid < 0) {
err("fork failed:", cpid);
}
if((execlp("tel", "tel", user, tty, what, (char *)0)) < 0)
perror("execlp tel failed\n");
_exit(EXIT_FAILURE);
}


while ((wpid= wait(&stats)) != cpid && wpid != -1)
;

return (WIFEXITED(stats) ? WEXITSTATUS(stats) : -2);
}


would calling wait() every 2 seconds, would I be 'polling'?

Chad

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com