Skip to content

Commit 440f330

Browse files
service: address review feedback on tty: stanza
1 parent 11c8b28 commit 440f330

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/service.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ static int service_start(svc_t *svc)
990990
* terminal on that device now that we're a session leader.
991991
* Must run after setsid() to acquire the controlling TTY.
992992
*/
993-
if (!svc_is_tty(svc) && svc->log.ctty[0])
993+
if (!svc_is_tty(svc) && svc_has_ctty(svc))
994994
svc_prepare_ctty(svc->log.ctty, svc->cmd, !!svc->log.enabled);
995995

996996
if (svc_is_runtask(svc))
@@ -2210,6 +2210,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
22102210
parse_caps(svc, caps);
22112211
else
22122212
memset(svc->capabilities, 0, sizeof(svc->capabilities));
2213+
22132214
if (!svc_is_tty(svc) && ctty) {
22142215
char *dev = ctty;
22152216

@@ -2221,7 +2222,10 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
22212222
strlcpy(svc->log.ctty, dev, sizeof(svc->log.ctty));
22222223
else
22232224
logit(LOG_WARNING, "%s: tty: %s not found, skipping ctty", svc_ident(svc, NULL, 0), ctty);
2225+
} else if (!svc_is_tty(svc)) {
2226+
memset(svc->log.ctty, 0, sizeof(svc->log.ctty));
22242227
}
2228+
22252229
if (file)
22262230
strlcpy(svc->file, file, sizeof(svc->file));
22272231
else

src/svc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ static inline int svc_in_runlevel (svc_t *svc, int runlevel) { return svc && IS
292292
static inline int svc_has_pidfile (svc_t *svc) { return svc_is_daemon(svc) && svc->pidfile[0] != 0 && svc->pidfile[0] != '!'; }
293293
static inline int svc_has_pre (svc_t *svc) { return svc->pre_script[0]; }
294294
static inline int svc_has_post (svc_t *svc) { return svc->post_script[0]; }
295+
static inline int svc_has_ctty (svc_t *svc) { return svc && svc->log.ctty[0]; }
295296
static inline int svc_has_ready (svc_t *svc) { return svc->ready_script[0];}
296297
static inline int svc_has_cleanup (svc_t *svc) { return svc->cleanup_script[0]; }
297298

0 commit comments

Comments
 (0)