aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-12-08 09:29:50 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-12-08 09:29:50 +0200
commit83513bddf4bd6c3ea5d42035bda4aaeae8086628 (patch)
treec4c18cad6150c42d6741325ec47b81baf551b645 /src/progman.c
parent261b55da70c1ab22c3729b823012ae30963f93d4 (diff)
downloadpies-83513bddf4bd6c3ea5d42035bda4aaeae8086628.tar.gz
pies-83513bddf4bd6c3ea5d42035bda4aaeae8086628.tar.bz2
Improve syslog redirection
* NEWS: Change wording a bit. * src/progman.c (redirect_to_file): Close and deregister the descriptor on error and EOF. * src/syslog.c (pies_log_tag): Rename to log_tag. (reopen_logger): Use PIES_LOG_DEV if log_dev is NULL. (pies_syslog_set_dev): Free previously allocated log_tag (if any).
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/progman.c b/src/progman.c
index c376615..02034ef 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -205,7 +205,7 @@ find_prog_ref (struct component *comp)
{
comp = comp->prev;
if (!comp)
- return NULL; /* FIXME: Skip redirectors? */
+ return NULL;
}
if (comp->prog)
@@ -312,12 +312,6 @@ progman_waiting_p (void)
return 0;
}
-RETSIGTYPE
-redir_exit (int sig)
-{
- _exit (0);
-}
-
int
redirect_to_file (struct prog *master, int stream)
{
@@ -370,11 +364,33 @@ redirect_read (int fd, void *data)
char const *tag = prog_tag (rb->master);
pid_t pid = rb->master->pid;
char *p;
+ static char *retr_stream_name[] = {
+ [RETR_OUT] = "stdout",
+ [RETR_ERR] = "stderr"
+ };
n = read (fd, rb->text + rb->len, sizeof (rb->text) - rb->len);
if (n == -1)
- return -1;
- if (n > 0)
+ {
+ if (errno != EINTR)
+ {
+ logmsg (LOG_INFO, _("%s: %s while reading %s"),
+ tag, strerror (errno), retr_stream_name[rb->stream]);
+ rb->master->v.p.redir[rb->stream] = -1;
+ close (fd);
+ deregister_socket (fd);
+ return -1;
+ }
+ }
+ else if (n == 0)
+ {
+ logmsg (LOG_INFO, _("%s: EOF on %s"),
+ tag, retr_stream_name[rb->stream]);
+ rb->master->v.p.redir[rb->stream] = -1;
+ close (fd);
+ deregister_socket (fd);
+ }
+ else
{
rb->len += n;

Return to:

Send suggestions and report system problems to the System administrator.