X-Git-Url: https://git.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=a882a6689c07ae06f91b3e95024ad8af589aa235;hb=48dd371b2ec69f02870aa5e2a67fc8adb4617ff1;hp=9b39f2ce19dd5ba55043718eae54e7200d47584d;hpb=a5c6c6ea1ab657d83a4d8b064ac9bfa9c16adf63;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index 9b39f2ce..a882a668 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -42,6 +42,7 @@ #include "keys.h" #include "random.h" #include "pidfile.h" +#include "console.h" #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 @@ -612,8 +613,9 @@ static void pcap(int fd, FILE *out, uint32_t snaplen) { } } -static void log_control(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]; @@ -955,7 +957,7 @@ static int cmd_start(int argc, char *argv[]) { 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 { @@ -1518,7 +1520,8 @@ static int cmd_log(int argc, char *argv[]) { signal(SIGINT, sigint_handler); #endif - log_control(fd, stdout, argc > 1 ? atoi(argv[1]) : DEBUG_UNSET); + 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);