#include "keys.h"
#include "random.h"
#include "pidfile.h"
+#include "console.h"
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
}
}
-static void logcontrol(int fd, FILE *out, int level) {
- sendline(fd, "%d %d %d", CONTROL, REQ_LOG, level);
+static void log_control(int fd, FILE *out, int level, bool use_color) {
+ sendline(fd, "%d %d %d %d", CONTROL, REQ_LOG, level, use_color);
+
char data[1024];
char line[32];
if(!pid) {
close(pfd[0]);
char buf[100];
- snprintf(buf, sizeof(buf), "%d", pfd[1]);
+ snprintf(buf, sizeof(buf), "%d %d", pfd[1], use_ansi_escapes(stderr));
setenv("TINC_UMBILICAL", buf, true);
exit(execvp(c, nargv));
} else {
signal(SIGINT, sigint_handler);
#endif
- logcontrol(fd, stdout, argc > 1 ? atoi(argv[1]) : -1);
+ bool use_color = use_ansi_escapes(stdout);
+ log_control(fd, stdout, argc > 1 ? atoi(argv[1]) : DEBUG_UNSET, use_color);
#ifdef SIGINT
signal(SIGINT, SIG_DFL);