[PATCH 6/7] support: Add support for starting and stopping nscd
DJ Delorie
dj@redhat.com
Tue Feb 10 20:06:15 GMT 2026
Florian Weimer <fweimer@redhat.com> writes:
> support/nscd.h | 39 ++++++++++++++
Note: there's an nscd.h in nscd/nscd.h and many of the files in nscd/
use the "nscd.h" include syntax. There's nothing in support/ which does
this, but given the existing code does... Files outside nscd/ use
<nscd/nscd.h> so that would avoid problems.
I don't see any problems with this, but let's be aware that there might
be later ;-)
> +/* Invalidate the specified database (group, hosts, netgroup, passwd,
> + services). It may be necessary to restart nscd. */
> +void support_nscd_invalidate (const char *database);
If restarting nscd is fast enough for the few tests which will use it,
perhaps we should just restart it unconditionally here?
Alternatively, we might want to leave it running to test that
configuration.
> +#include <support/nscd.h>
> +
> +#include <libgen.h>
> +#include <signal.h>
> +#include <spawn.h>
> +#include <stdbool.h>
> +#include <stdlib.h>
> +#include <support/check.h>
> +#include <support/support.h>
> +#include <support/xspawn.h>
> +#include <support/xunistd.h>
> +#include <sys/wait.h>
> +#include <unistd.h>
Do we have any guidelines on which order we should include includes in?
I've always done system includes first, then local ones, which means
<support/*> would be much further down the list.
> + while (true)
> + {
> + if (access (_PATH_NSCDSOCKET, F_OK) == 0)
> + break;
> + int status;
> + int ret = waitpid (nscd_pid, &status, WNOHANG);
> + if (ret < 0)
> + FAIL_EXIT1 ("waitpid on nscd failed: %m");
> + else if (ret > 0)
> + FAIL_EXIT1 ("nscd exited with status %d", status);
> + usleep (10 * 1000);
> + }
> +}
This needs a comment. I think what it's doing is waiting for nscd to
become ready, yes?
> +void
> +support_nscd_stop (void)
> +{
> + char *cmd = xasprintf ("%s/nscd/nscd --shutdown", support_objdir_root);
It occurs to me... why isn't nscd installed in the testroot, and should
we test that? I don't think nscd cares what path it's run from, but...
It wouldn't remove the need to call xasprintf though.
Otherwise LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
More information about the Libc-alpha
mailing list