dtsession: also block HUP and PIPE when preparing to shutdown
[oweals/cde.git] / cde / programs / dtsession / SmUI.c
index bdd0d90b05194b114d563a176e2cf9cc97fcc025..ada4756816d5c773fd2def59c46a8705b2a72237 100644 (file)
@@ -1,3 +1,25 @@
+/*
+ * CDE - Common Desktop Environment
+ *
+ * Copyright (c) 1993-2012, The Open Group. All rights reserved.
+ *
+ * These libraries and programs are free software; you can
+ * redistribute them and/or modify them under the terms of the GNU
+ * Lesser General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * These libraries and programs are distributed in the hope that
+ * they will be useful, but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with these librararies and programs; if not, write
+ * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301 USA
+ */
 /* $TOG: SmUI.c /main/32 1998/07/23 18:08:17 mgreess $ */
 /*                                                                      *
  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
@@ -1135,6 +1157,8 @@ ImmediateExit(
      */
 #if !defined(SVR4) && !defined(sco)
     old = sigblock(sigmask(SIGTERM));
+    sigblock(sigmask(SIGHUP));
+    sigblock(sigmask(SIGPIPE));
 #else
     old = sighold(SIGTERM);
 #endif
@@ -1186,6 +1210,11 @@ ImmediateExit(
 
        smGD.loggingOut = True;
 
+        /* JET - set this here so we don't exit prematurely (while
+         * handling our own SM exit callback - duh).
+         */
+       smGD.ExitComplete = False;
+
         saveTimeout = False;
        timerId = XtAppAddTimeOut (smGD.appCon, smRes.saveYourselfTimeout, 
                                   SaveTimeout, NULL);
@@ -1199,6 +1228,13 @@ ImmediateExit(
                XtDispatchEvent(&next);
        }
     }
+    
+    /* JET - need this, since dtsession was exiting in the
+     * XtAppNextEvent above (receiving it's own EXIT SM message) This
+     * is checked in SmExit() so exit's will only occur after this
+     * housekeeping has been completed.
+     */
+    smGD.ExitComplete = True; 
 
     if (smXSMP.saveState.shutdownCanceled == False) {
        /* 
@@ -2094,6 +2130,7 @@ PostXSMPFailureDialog (
        Dimension       width, height;
        Position        x, y;
        XEvent          next;
+        int             len;
 
        pch1 = strdup ((char *) GETMESSAGE(40, 1, 
                "A session cannot be started because of the\nfollowing error:"));
@@ -2149,13 +2186,26 @@ PostXSMPFailureDialog (
 
        error_file = XtMalloc(MAXPATHLEN+1);
        strcpy (error_file, "");
-       if (check_errorlog) {
-               char            *home;
 
-               if (home = getenv ("HOME"))
-                       sprintf (error_file, "%s/%s/%s", home, DtPERSONAL_CONFIG_DIRECTORY,
-                                        DtERRORLOG_FILE);
-       }
+        /* JET - VU#497553 */
+       if (check_errorlog) 
+         {
+           char                *home;
+
+           if (home = getenv ("HOME"))
+             {
+               len = strlen(home) +
+                 strlen(DtPERSONAL_CONFIG_DIRECTORY) +
+                 strlen(DtERRORLOG_FILE);
+
+               if (len > MAXPATHLEN)
+                 error_file = XtRealloc(error_file, len + 1);
+
+               sprintf (error_file, "%s/%s/%s", home, 
+                        DtPERSONAL_CONFIG_DIRECTORY,
+                        DtERRORLOG_FILE);
+             }
+         }
 
        pch5 = XtMalloc (strlen (pch1) + strlen (pch2) + strlen (pch3) + strlen (pch4) + 
                                strlen (error_file) + 15);