Only call pv_watchfd_loop() from main, so that eventually pv_watchpid_loop() can be removed and multiple "-d" values supported (#12).
This commit is contained in:
+2
-7
@@ -547,13 +547,8 @@ int main(int argc, char **argv)
|
||||
pv_remote_fini();
|
||||
break;
|
||||
case PV_ACTION_WATCHFD:
|
||||
if ((opts->watchfd_count > 0) && (NULL != opts->watchfd_fd) && (-1 == opts->watchfd_fd[0])) {
|
||||
/* "Watch all file descriptors of another process" mode. */
|
||||
retcode = pv_watchpid_loop(state);
|
||||
} else if ((opts->watchfd_count > 0) && (NULL != opts->watchfd_fd) && (-1 != opts->watchfd_fd[0])) {
|
||||
/* "Watch a specific file descriptor of another process" mode. */
|
||||
retcode = pv_watchfd_loop(state);
|
||||
}
|
||||
/* "Watch file descriptor(s) of another process" mode. */
|
||||
retcode = pv_watchfd_loop(state);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -591,6 +591,7 @@ int pv_main_loop(pvstate_t state)
|
||||
* Returns nonzero on error.
|
||||
*
|
||||
* TODO: unify this with pv_watchpid_loop.
|
||||
* TODO: watch more than one fd, if watchfd.count > 1.
|
||||
*/
|
||||
int pv_watchfd_loop(pvstate_t state)
|
||||
{
|
||||
@@ -609,6 +610,11 @@ int pv_watchfd_loop(pvstate_t state)
|
||||
if (NULL == state->watchfd.fd)
|
||||
return PV_ERROREXIT_MEMORY;
|
||||
|
||||
/* Call pv_watchpid_loop() instead if no specific fd was given. */
|
||||
if (-1 == state->watchfd.fd[0]) {
|
||||
return pv_watchpid_loop(state);
|
||||
}
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.watch_pid = state->watchfd.pid[0];
|
||||
info.watch_fd = state->watchfd.fd[0];
|
||||
|
||||
Reference in New Issue
Block a user