From 056d3c8e6481088b8e5d9791d8c1762a3c8d1a83 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 22 Jul 2018 17:57:13 +0200 Subject: Add output truncation flag This commit adds a "truncate" flag that can be added to a service description between the "tty" keyword and the path string. If the flag is set, the output file is truncated to 0 after opening. This probably requires some remodeling in the future as the tty keyword no longer deals with just tty devices. Signed-off-by: David Oberhollenzer --- lib/util/rdsvc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/util/rdsvc.c') diff --git a/lib/util/rdsvc.c b/lib/util/rdsvc.c index 6a964f7..37c7ba0 100644 --- a/lib/util/rdsvc.c +++ b/lib/util/rdsvc.c @@ -70,8 +70,16 @@ static int svc_desc(service_t *svc, char *arg, rdline_t *rd) static int svc_tty(service_t *svc, char *arg, rdline_t *rd) { + if (strncmp(arg, "truncate", 8) == 0 && isspace(arg[8])) { + svc->flags |= SVC_FLAG_TRUNCATE_OUT; + arg += 8; + while (isspace(*arg)) + ++arg; + } + if (try_unescape(arg, rd)) return -1; + svc->ctty = try_strdup(arg, rd); return svc->ctty == NULL ? -1 : 0; } -- cgit v1.2.3