When starting tincd, tincctl now strips non-options from the command line, and
sets argv[0] to the name of the tincd command instead of copying its own
command name.
When stopping a running tincd, tincctl now waits for it to terminate.
c = "tincd";
int nargc = 0;
c = "tincd";
int nargc = 0;
- char **nargv = xmalloc_and_zero((orig_argc + argc) * sizeof *nargv);
+ char **nargv = xmalloc_and_zero((optind + argc) * sizeof *nargv);
- for(int i = 0; i < orig_argc; i++)
+ nargv[nargc++] = c;
+ for(int i = 1; i < optind; i++)
nargv[nargc++] = orig_argv[i];
for(int i = 1; i < argc; i++)
nargv[nargc++] = argv[i];
nargv[nargc++] = orig_argv[i];
for(int i = 1; i < argc; i++)
nargv[nargc++] = argv[i];
#ifndef HAVE_MINGW
if(!connect_tincd(true)) {
if(pid) {
#ifndef HAVE_MINGW
if(!connect_tincd(true)) {
if(pid) {
+ if(kill(pid, SIGTERM)) {
+ fprintf(stderr, "Could not send TERM signal to process with PID %u: %s\n", pid, strerror(errno));
fprintf(stderr, "Sent TERM signal to process with PID %u.\n", pid);
fprintf(stderr, "Sent TERM signal to process with PID %u.\n", pid);
fprintf(stderr, "Could not stop tinc daemon.\n");
return 1;
}
fprintf(stderr, "Could not stop tinc daemon.\n");
return 1;
}
+
+ // Wait for tincd to close the connection...
+ fd_set r;
+ FD_ZERO(&r);
+ FD_SET(fd, &r);
+ select(fd + 1, &r, NULL, NULL, NULL);
#else
if(!remove_service())
return 1;
#else
if(!remove_service())
return 1;
char *line = NULL;
int maxargs = argc + 16;
char **nargv = xmalloc(maxargs * sizeof *nargv);
char *line = NULL;
int maxargs = argc + 16;
char **nargv = xmalloc(maxargs * sizeof *nargv);
for(int i = 0; i < argc; i++)
nargv[i] = argv[i];
for(int i = 0; i < argc; i++)
nargv[i] = argv[i];