[PATCH] Avoid having a dead Plymouth cause clients to get SIGPIPE'd
Soren Hansen
soren at linux2go.dk
Sat Feb 12 06:39:43 PST 2011
If Plymouth dies for some reason, clients will get SIGPIPE'd next time
they try to talk to it. Address this by passing MSG_NOSIGNAL to send
and leave it to standard errno handling to deal with the error.
Signed-off-by: Soren Hansen <soren at linux2go.dk>
---
configure.ac | 2 ++
src/libply/ply-utils.c | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2209df1..02bd2e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -280,6 +280,8 @@ AC_DEFINE_UNQUOTED(BOOT_TTY, "$BOOT_TTY", [TTY to use in boot mode])
AC_ARG_WITH(shutdown-tty, AS_HELP_STRING([--with-shutdown-tty=<tty>],[Default TTY to use in shutdown mode (by default tty63)]),SHUTDOWN_TTY=${withval},SHUTDOWN_TTY=/dev/tty63)
AC_DEFINE_UNQUOTED(SHUTDOWN_TTY, "$SHUTDOWN_TTY", [TTY to use in shutdown mode])
+AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [[ #include <sys/socket.h> ]])
+
# Turn on the additional warnings last, so -Werror doesn't affect other tests.
AC_DEFUN([PLYMOUTH_CC_TRY_FLAG], [
diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c
index 5b06e49..2591444 100644
--- a/src/libply/ply-utils.c
+++ b/src/libply/ply-utils.c
@@ -315,9 +315,14 @@ ply_write (int fd,
{
ssize_t bytes_written = 0;
- bytes_written = write (fd,
+ bytes_written = send (fd,
((uint8_t *) buffer) + total_bytes_written,
- bytes_left_to_write);
+ bytes_left_to_write,
+ 0
+#if HAVE_DECL_MSG_NOSIGNAL
+ |MSG_NOSIGNAL
+#endif
+ );
if (bytes_written > 0)
{
--
1.7.2.3
More information about the plymouth
mailing list