Skip to content

Commit b803986

Browse files
committed
libflux: drop child watchers
Problem: child watchers have no users, are likely not required in the public API, and inhibit changing the internal reactor to libuv. Drop them. Fixes #6512
1 parent 300c7a1 commit b803986

File tree

3 files changed

+0
-145
lines changed

3 files changed

+0
-145
lines changed

src/common/libflux/test/reactor.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -553,52 +553,6 @@ static void test_signal (flux_reactor_t *reactor)
553553
flux_watcher_destroy (idle);
554554
}
555555

556-
static pid_t child_pid = -1;
557-
static void child_cb (flux_reactor_t *r,
558-
flux_watcher_t *w,
559-
int revents,
560-
void *arg)
561-
{
562-
int pid = flux_child_watcher_get_rpid (w);
563-
int rstatus = flux_child_watcher_get_rstatus (w);
564-
ok (pid == child_pid,
565-
"child watcher called with expected rpid");
566-
ok (WIFSIGNALED (rstatus) && WTERMSIG (rstatus) == SIGHUP,
567-
"child watcher called with expected rstatus");
568-
flux_watcher_stop (w);
569-
}
570-
571-
static void test_child (flux_reactor_t *reactor)
572-
{
573-
flux_watcher_t *w;
574-
flux_reactor_t *r;
575-
576-
child_pid = fork ();
577-
if (child_pid == 0) {
578-
pause ();
579-
exit (0);
580-
}
581-
errno = 0;
582-
w = flux_child_watcher_create (reactor, child_pid, false, child_cb, NULL);
583-
ok (w == NULL && errno == EINVAL,
584-
"child watcher failed with EINVAL on non-SIGCHLD reactor");
585-
ok ((r = flux_reactor_create (FLUX_REACTOR_SIGCHLD)) != NULL,
586-
"created reactor with SIGCHLD flag");
587-
w = flux_child_watcher_create (r, child_pid, false, child_cb, NULL);
588-
ok (w != NULL,
589-
"created child watcher");
590-
generic_watcher_check (w, "signal");
591-
592-
ok (kill (child_pid, SIGHUP) == 0,
593-
"sent child SIGHUP");
594-
flux_watcher_start (w);
595-
596-
ok (flux_reactor_run (r, 0) == 0,
597-
"reactor ran successfully");
598-
flux_watcher_destroy (w);
599-
flux_reactor_destroy (r);
600-
}
601-
602556
struct stat_ctx {
603557
int fd;
604558
char *path;
@@ -953,7 +907,6 @@ int main (int argc, char *argv[])
953907
test_idle (reactor);
954908
test_prepcheck (reactor);
955909
test_signal (reactor);
956-
test_child (reactor);
957910
test_stat (reactor);
958911
test_handle (reactor);
959912
test_unref (reactor);

src/common/libflux/watcher.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,6 @@ flux_watcher_t *flux_idle_watcher_create (flux_reactor_t *r,
107107
flux_watcher_f cb,
108108
void *arg);
109109

110-
/* child
111-
*/
112-
113-
flux_watcher_t *flux_child_watcher_create (flux_reactor_t *r,
114-
int pid,
115-
bool trace,
116-
flux_watcher_f cb,
117-
void *arg);
118-
int flux_child_watcher_get_rpid (flux_watcher_t *w);
119-
int flux_child_watcher_get_rstatus (flux_watcher_t *w);
120-
121110
/* signal
122111
*/
123112

src/common/libflux/watcher_wrap.c

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -642,93 +642,6 @@ flux_watcher_t *flux_idle_watcher_create (flux_reactor_t *r,
642642
return w;
643643
}
644644

645-
/* Child
646-
*/
647-
648-
struct child_watcher {
649-
ev_child evw;
650-
};
651-
652-
static void child_watcher_start (flux_watcher_t *w)
653-
{
654-
struct ev_loop *loop = watcher_get_ev (w);
655-
struct child_watcher *cw = watcher_get_data (w);
656-
bool active = ev_is_active (&cw->evw);
657-
ev_child_start (loop, &cw->evw);
658-
watcher_start_post_ev (w, active);
659-
}
660-
661-
static void child_watcher_stop (flux_watcher_t *w)
662-
{
663-
struct ev_loop *loop = watcher_get_ev (w);
664-
struct child_watcher *cw = watcher_get_data (w);
665-
watcher_stop_pre_ev (w);
666-
ev_child_stop (loop, &cw->evw);
667-
}
668-
669-
static bool child_watcher_is_active (flux_watcher_t *w)
670-
{
671-
struct child_watcher *cw = watcher_get_data (w);
672-
return ev_is_active (&cw->evw);
673-
}
674-
675-
static void child_watcher_cb (struct ev_loop *loop, ev_child *evw, int revents)
676-
{
677-
struct flux_watcher *w = evw->data;
678-
watcher_call_ev (w, revents);
679-
}
680-
681-
static struct flux_watcher_ops child_watcher_ops = {
682-
.start = child_watcher_start,
683-
.stop = child_watcher_stop,
684-
.ref = watcher_ref_ev,
685-
.unref = watcher_unref_ev,
686-
.is_active = child_watcher_is_active,
687-
.destroy = NULL,
688-
};
689-
690-
flux_watcher_t *flux_child_watcher_create (flux_reactor_t *r,
691-
int pid,
692-
bool trace,
693-
flux_watcher_f cb,
694-
void *arg)
695-
{
696-
flux_watcher_t *w;
697-
struct child_watcher *cw;
698-
699-
if (!ev_is_default_loop (reactor_get_loop (r))) {
700-
errno = EINVAL;
701-
return NULL;
702-
}
703-
if (!(w = watcher_create (r, sizeof (*cw), &child_watcher_ops, cb, arg)))
704-
return NULL;
705-
cw = watcher_get_data (w);
706-
ev_child_init (&cw->evw, child_watcher_cb, pid, trace ? 1 : 0);
707-
cw->evw.data = w;
708-
709-
return w;
710-
}
711-
712-
int flux_child_watcher_get_rpid (flux_watcher_t *w)
713-
{
714-
if (watcher_get_ops (w) != &child_watcher_ops) {
715-
errno = EINVAL;
716-
return -1;
717-
}
718-
struct child_watcher *cw = watcher_get_data (w);
719-
return cw->evw.rpid;
720-
}
721-
722-
int flux_child_watcher_get_rstatus (flux_watcher_t *w)
723-
{
724-
if (watcher_get_ops (w) != &child_watcher_ops) {
725-
errno = EINVAL;
726-
return -1;
727-
}
728-
struct child_watcher *cw = watcher_get_data (w);
729-
return cw->evw.rstatus;
730-
}
731-
732645
/* Signal
733646
*/
734647

0 commit comments

Comments
 (0)