aboutsummaryrefslogtreecommitdiff
path: root/src/ctl.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-11-22 19:39:29 +0100
committerSergey Poznyakoff <gray@gnu.org.ua>2015-11-22 19:39:29 +0100
commit944f922aebac63e0a668b4d9abae418a57a6720d (patch)
treef27bf9fd339a840201e286369818ceb3cbe877c4 /src/ctl.c
parente7e3df9a6c4599f982a62bb8d7cd973ccd8cee72 (diff)
downloadpies-944f922aebac63e0a668b4d9abae418a57a6720d.tar.gz
pies-944f922aebac63e0a668b4d9abae418a57a6720d.tar.bz2
Bugfixes
* src/ctl.c (cmd_reboot, ctl_shutdown): Use code 221 to indicate that we are going to close clonnection (ctlwr): Check return from write. * src/pies.c: Handle SIGPIPE
Diffstat (limited to 'src/ctl.c')
-rw-r--r--src/ctl.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/ctl.c b/src/ctl.c
index eef1aae..f9f2d76 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -890,21 +890,21 @@ cmd_restart (struct ctlio *io, size_t argc, char **argv)
static void
cmd_reboot (struct ctlio *io, size_t argc, char **argv)
{
io->action = ACTION_RESTART;
io->state = CTL_ACTION_STATE;
- ctlio_reply (io, "250", "Rebooting, closing connection");
+ ctlio_reply (io, "221", "Rebooting, closing connection");
}
static void
cmd_shutdown (struct ctlio *io, size_t argc, char **argv)
{
io->action = ACTION_STOP;
io->state = CTL_ACTION_STATE;
- ctlio_reply (io, "250", "Shuttign down, connection will be closed");
+ ctlio_reply (io, "221", "Shutting down, connection will be closed");
}
static int ctlrd (int fd, void *data);
static int ctlwr (int fd, void *data);
static int
@@ -948,13 +948,23 @@ static int
ctlwr (int fd, void *data)
{
char c;
struct ctlio *io = data;
// logmsg (LOG_DEBUG, "%s called", __FUNCTION__);
if (ctlbuf_read (&io->obuf, &c, 1))
- write (fd, &c, 1);
+ {
+ ssize_t rc = write (fd, &c, 1);
+ if (rc != 1) {
+ if (rc == 0)
+ logmsg (LOG_ERR, "error writing to control socket");
+ else
+ logmsg (LOG_ERR, "error writing to control socket: %s",
+ strerror (errno));
+ return ctlio_end (fd, io);
+ }
+ }
else if (io->state == CTL_END_STATE)
return ctlio_end (fd, io);
else if (io->state == CTL_ACTION_STATE)
{
pies_schedule_action (io->action);
return ctlio_end (fd, io);

Return to:

Send suggestions and report system problems to the System administrator.