From 07f873d107539a4357c69e1f3ce8cef17cc6277f Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Sat, 25 Apr 1998 02:23:26 +0000 Subject: Fixed alarm saving code. Fixed alarm loading code. New -partial- Fixed alarm saving code. Fixed alarm loading code. New -partial- implementation of the mail alarm. It is not working, I do not know what is closing stdin to sendmail svn path=/trunk/; revision=194 --- calendar/gui/gnome-cal.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'calendar/gui/gnome-cal.c') diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 755785836a..534db8bb4c 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "calendar.h" #include "gnome-cal.h" #include "gncal-day-panel.h" @@ -257,9 +258,9 @@ execute (char *command, int close_standard) */ execl ("/bin/sh", "/bin/sh", "-c", command, (char *) 0); - exit (127); + _exit (127); } else { - exit (127); + _exit (127); } } wait (&status); @@ -285,13 +286,31 @@ calendar_notify (time_t time, void *data) if (ico->malarm.enabled && ico->malarm.trigger == time){ char *command; time_t app = ico->malarm.trigger + ico->malarm.offset; + pid_t pid; + int p [2]; - command = g_copy_strings ("mail -s '", - _("Reminder of your appointment at "), - ctime (&app), "' '", - ico->malarm.data, "' ", - NULL); - execute (command, 1); + pipe (p); + pid = fork (); + if (pid == 0){ + const int top = max_open_files (); + int dev_null, i; + + for (i = 0; i < top; i++) + if (i != p [1]) + close (i); + dev_null = open ("/dev/null", O_RDWR); + dup2 (p [1], 0); + dup2 (dev_null, 1); + dup2 (dev_null, 2); + execl ("/usr/lib/sendmail", "/usr/lib/sendmail", + ico->malarm.data, NULL); + _exit (127); + } + close (p [1]); + command = g_copy_strings ("To: ", ico->malarm.data, "\n", + "Subject: ", _("Reminder of your appointment at "), + ctime (&app), "\n\n", NULL); + write (p [0], command, strlen (command)); g_free (command); return; -- cgit v1.2.3