Skip to content
Snippets Groups Projects
Commit 8f39bbf3 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

add svc_send_wait() function

parent 942e797a
No related branches found
No related tags found
No related merge requests found
svc_scandir_ok.o
svc_scandir_send.o
svc_send.o
svc_send_wait.o
svc_unsupervise.o
-ls6
-loblibs
......
/*
* svc_send_wait.c
*
* Copyright (c) 2018-2022 Eric Vidal <eric@obarun.org>
*
* All rights reserved.
*
* This file is part of Obarun. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this
* distribution.
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file./
*/
#include <oblibs/log.h>
#include <skalibs/djbunix.h>
#include <66/svc.h>
#include <66/resolve.h>
#include <66/ssexec.h>
int svc_send_wait(char const *const *list, unsigned int nservice, char **sig, unsigned int siglen, ssexec_t *info)
{
log_flow() ;
pid_t pid ;
int wstat ;
int nargc = 5 + nservice + siglen + info->opt_color ;
char const *newargv[nargc] ;
unsigned int m = 0 ;
char verbo[UINT_FMT] ;
verbo[uint_fmt(verbo, VERBOSITY)] = 0 ;
newargv[m++] = "66" ;
newargv[m++] = "svctl" ;
if (info->opt_color)
newargv[m++] = "-z" ;
newargv[m++] = "-v" ;
newargv[m++] = verbo ;
for (; *sig ; sig++)
newargv[m++] = *sig ;
for (; *list ; list++)
newargv[m++] = *list ;
newargv[m++] = 0 ;
pid = child_spawn0(newargv[0], newargv, (char const *const *) environ) ;
if (waitpid_nointr(pid, &wstat, 0) < 0)
log_warnusys_return(LOG_EXIT_SYS, "wait for svctl") ;
if (wstat)
log_warnu_return(WIFSIGNALED(wstat) ? WTERMSIG(wstat) : WEXITSTATUS(wstat), "stop services selection") ;
return 0 ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment