summaryrefslogtreecommitdiff
path: root/workInProgress
diff options
context:
space:
mode:
authordawes <dawes>1995-01-27 05:02:12 +0000
committerdawes <dawes>1995-01-27 05:02:12 +0000
commite52d61f8a385288a976b085652c5e07df3041e4b (patch)
tree40f42d0e5aef093b9330b18b41916e26eae8ef2f /workInProgress
parent478b52f6b6640bf414f488187cb5e6e8479ac27b (diff)
merge XC fix-08
Diffstat (limited to 'workInProgress')
-rw-r--r--workInProgress/xsm/Imakefile44
-rw-r--r--workInProgress/xsm/restart.c610
-rw-r--r--workInProgress/xsm/xsm.h157
3 files changed, 631 insertions, 180 deletions
diff --git a/workInProgress/xsm/Imakefile b/workInProgress/xsm/Imakefile
index 99b8be102..0ca84dfb7 100644
--- a/workInProgress/xsm/Imakefile
+++ b/workInProgress/xsm/Imakefile
@@ -1,5 +1,5 @@
-XCOMM $XConsortium: Imakefile,v 1.7 94/02/22 15:42:37 mor Exp $
-XCOMM $XFree86$
+XCOMM $XConsortium: Imakefile,v 1.16 94/12/27 17:42:37 mor Exp $
+XCOMM $XFree86: xc/workInProgress/xsm/Imakefile,v 3.0 1994/06/28 12:41:21 dawes Exp $
#if !defined(RshCmd)
#if SystemV
#ifdef HPArchitecture
@@ -12,34 +12,30 @@ XCOMM $XFree86$
#endif
#endif
+#ifdef MinixArchitecture
+ SHELLSRC = Shell.c
+ SHELLOBJ = Shell.o
+#endif
+
RSHCMD = RshCmd
DEPLIBS = XawClientDepLibs
LOCAL_LIBRARIES = XawClientLibs
-#ifdef MinixArchitecture
- SRCS1 = auth.c list.c misc.c printhex.c remote.c restart.c save.c \
- xsm.c xtwatch.c Shell.c
-
- OBJS1 = auth.o list.o misc.o printhex.o remote.o restart.o save.o \
- xsm.o xtwatch.o Shell.o
-#else
- SRCS1 = auth.c list.c misc.c printhex.c remote.c restart.c save.c \
- xsm.c xtwatch.c
+ SRCS1 = auth.c choose.c info.c list.c lock.c log.c \
+ mainwin.c misc.c popup.c printhex.c prop.c remote.c \
+ restart.c save.c saveutil.c signals.c xsm.c xtwatch.c \
+ $(SHELLSRC)
- OBJS1 = auth.o list.o misc.o printhex.o remote.o restart.o save.o \
- xsm.o xtwatch.o
-#endif
+ OBJS1 = auth.o choose.o info.o list.o lock.o log.o \
+ mainwin.o misc.o popup.o printhex.o prop.o remote.o \
+ restart.o save.o saveutil.o signals.o xsm.o xtwatch.o \
+ $(SHELLOBJ)
PROGS1 = xsm
-#ifdef MinixArchitecture
- SRCS2 = xsmclient.c Shell.c
- OBJS2 = xsmclient.o Shell.o
-#else
- SRCS2 = xsmclient.c
- OBJS2 = xsmclient.o
-#endif
+ SRCS2 = xsmclient.c $(SHELLSRC)
+ OBJS2 = xsmclient.o $(SHELLOBJ)
PROGS2 = xsmclient
SRCS = $(SRCS1) $(SRCS2)
@@ -52,6 +48,10 @@ SpecialCObjectRule(remote,NullParameter,'-DRSHCMD="$(RSHCMD)"')
#if !HasPutenv
SpecialCObjectRule(misc,NullParameter,-DNOPUTENV)
#endif
+SpecialCObjectRule(restart,$(_NOOP_),'-DSYSTEM_INIT_FILE="'$(XSMDIR)'/system.xsm"')
+SpecialCObjectRule(signals,NullParameter,$(SIGNAL_DEFINES))
#ifdef MinixArchitecture
-ObjectFromSpecialSource(Shell,../../lib/Xt/Shell,-I../../lib/Xt)
+ObjectFromSpecialSource(Shell,$(TOOLKITSRC)/Shell,-I$(TOOLKITSRC))
#endif
+InstallNonExecFile(system.xsm,$(XSMDIR))
+InstallAppDefaults(XSm)
diff --git a/workInProgress/xsm/restart.c b/workInProgress/xsm/restart.c
index f045d5a36..3f9d68918 100644
--- a/workInProgress/xsm/restart.c
+++ b/workInProgress/xsm/restart.c
@@ -1,5 +1,5 @@
-/* $XConsortium: restart.c,v 1.5 94/05/12 11:59:01 mor Exp $ */
-/* $XFree86$ */
+/* $XConsortium: restart.c,v 1.25 95/01/03 17:30:37 mor Exp $ */
+/* $XFree86: xc/workInProgress/xsm/restart.c,v 3.0 1994/06/28 12:41:22 dawes Exp $ */
/******************************************************************************
Copyright (c) 1993 X Consortium
@@ -27,127 +27,157 @@ in this Software without prior written authorization from the X Consortium.
******************************************************************************/
#include "xsm.h"
+#include "log.h"
-extern List *PendingList;
extern void remote_start ();
-void
-restart_everything()
+/*
+ * Until XSMP provides a better way to know which clients are "managers",
+ * we have to hard code the list.
+ */
+
+Bool
+CheckIsManager (program)
+
+char *program;
+
{
- List *cl;
- List *pl;
- List *vl;
- PendingClient *c;
- PendingProp *prop;
- PendingValue *v;
- char *cwd;
- char *program;
- char **args;
- char **env;
-#ifdef MINIX
- char *no_env= NULL;
-#endif
- char **pp;
- int cnt;
- extern char **environ;
- char *p, *temp;
- static char envDISPLAY[]="DISPLAY";
- static char envSESSION_MANAGER[]="SESSION_MANAGER";
- static char envAUDIOSERVER[]="AUDIOSERVER";
- char *display_env, *non_local_display_env;
- char *session_env, *non_local_session_env;
- char *audio_env;
- int remote_allowed = 1;
-
- display_env = NULL;
- if(p = (char *) getenv(envDISPLAY)) {
- display_env = (char *) malloc(strlen(envDISPLAY)+1+strlen(p)+1);
- if(!display_env) nomem();
- sprintf(display_env, "%s=%s", envDISPLAY, p);
+ return (strcmp (program, "twm") == 0);
+}
- /*
- * When we restart a remote client, we have to make sure the
- * display environment we give it has the SM's hostname.
- */
- if ((temp = strchr (p, '/')) == 0)
- temp = p;
- else
- temp++;
+
+/*
+ * GetRestartInfo() will determine which method should be used to
+ * restart a client.
+ *
+ * 'restart_service_prop' is a property set by the client, or NULL.
+ * The format is "remote_start_protocol/remote_start_data". An
+ * example is "rstart-rsh/hostname". This is a non-standard property,
+ * which is the whole reason we need this function in order to determine
+ * the restart method. The proxy uses this property to over-ride the
+ * 'client_host_name' from the ICE connection (the proxy is connected to
+ * the SM via a local connection, but the proxy may be acting as a proxy
+ * for a remote client).
+ *
+ * 'client_host_name' is the connection info obtained from the ICE
+ * connection. It's format is "transport/host_info". An example
+ * is "tcp/machine:port".
+ *
+ * If 'restart_service_prop' is NULL, we use 'client_host_name' to
+ * determine the restart method. If the transport is "local", we
+ * do a local restart. Otherwise, we use the default "rstart-rsh" method.
+ *
+ * If 'restart_service_prop' is non-NULL, we check the remote_start_protocol
+ * field. "local" means a local restart. Currently, the only remote
+ * protocol we recognize is "rstart-rsh". If the remote protocol is
+ * "rstart-rsh" but the hostname in the 'restart_service_prop' matches
+ * 'client_host_name', we do a local restart.
+ *
+ * On return, set the run_local flag, restart_protocol and restart_machine.
+ */
- if (*temp != ':')
- {
- /* we have a host name */
+void
+GetRestartInfo (restart_service_prop, client_host_name,
+ run_local, restart_protocol, restart_machine)
- non_local_display_env = (char *) malloc (strlen (display_env) + 1);
- if (!non_local_display_env) nomem();
+char *restart_service_prop;
+char *client_host_name;
+Bool *run_local;
+char **restart_protocol;
+char **restart_machine;
+
+{
+ char hostnamebuf[80];
+ char *temp;
- strcpy (non_local_display_env, display_env);
+ *run_local = False;
+ *restart_protocol = NULL;
+ *restart_machine = NULL;
+
+ if (restart_service_prop)
+ {
+ gethostname (hostnamebuf, sizeof hostnamebuf);
+
+ if ((temp = (char *) strchr (
+ restart_service_prop, '/')) == NULL)
+ {
+ *restart_protocol = (char *) XtNewString ("rstart-rsh");
+ *restart_machine = (char *) XtNewString (restart_service_prop);
}
else
{
- char hostnamebuf[256];
-
- gethostname (hostnamebuf, sizeof hostnamebuf);
- non_local_display_env = (char *) malloc (strlen (envDISPLAY) + 1 +
- strlen (hostnamebuf) + strlen (temp) + 1);
- if (!non_local_display_env) nomem();
- sprintf(non_local_display_env, "%s=%s%s",
- envDISPLAY, hostnamebuf, temp);
+ *restart_protocol = (char *) XtNewString (restart_service_prop);
+ (*restart_protocol)[temp - restart_service_prop] = '\0';
+ *restart_machine = (char *) XtNewString (temp + 1);
}
- }
-
- session_env = NULL;
- if(p = (char *) getenv(envSESSION_MANAGER)) {
- session_env = (char *) malloc(
- strlen(envSESSION_MANAGER)+1+strlen(p)+1);
- if(!session_env) nomem();
- sprintf(session_env, "%s=%s", envSESSION_MANAGER, p);
- /*
- * When we restart a remote client, we have to make sure the
- * session environment does not have the SM's local connection port.
- */
-
- non_local_session_env = (char *) malloc (strlen (session_env) + 1);
- if (!non_local_session_env) nomem();
- strcpy (non_local_session_env, session_env);
-
- if ((temp = Strstr (non_local_session_env, "local/")) != NULL)
+ if (strcmp (*restart_machine, hostnamebuf) == 0 ||
+ strcmp (*restart_protocol, "local") == 0)
+ {
+ *run_local = True;
+ }
+ }
+ else
+ {
+ if (strncmp (client_host_name, "tcp/", 4) != 0 &&
+ strncmp (client_host_name, "decnet/", 7) != 0)
+ {
+ *run_local = True;
+ }
+ else
{
- char *delim = strchr (temp, ',');
- if (delim == NULL)
+ *restart_protocol = (char *) XtNewString ("rstart-rsh");
+
+ if ((temp = (char *) strchr (
+ client_host_name, '/')) == NULL)
{
- if (temp == non_local_session_env +
- strlen (envSESSION_MANAGER) + 1)
- {
- *temp = '\0';
- remote_allowed = 0;
- }
- else
- *(temp - 1) = '\0';
+ *restart_machine = (char *) XtNewString (client_host_name);
}
else
{
- int bytes = strlen (delim + 1);
- memmove (temp, delim + 1, bytes);
- *(temp + bytes) = '\0';
+ *restart_machine = (char *) XtNewString (temp + 1);
}
}
}
+}
- audio_env = NULL;
- if(p = (char *) getenv(envAUDIOSERVER)) {
- audio_env = (char *) malloc(strlen(envAUDIOSERVER)+1+strlen(p)+1);
- if(!audio_env) nomem();
- sprintf(audio_env, "%s=%s", envAUDIOSERVER, p);
- }
+
+
+/*
+ * Restart clients. The flag indicates RESTART_MANAGERS or
+ * RESTART_REST_OF_CLIENTS.
+ */
+
+Status
+Restart (flag)
+
+int flag;
+
+{
+ List *cl, *pl, *vl;
+ PendingClient *c;
+ Prop *prop;
+ char *cwd;
+ char *program;
+ char **args;
+ char **env;
+ char **pp;
+ int cnt;
+ extern char **environ;
+ char *p;
+ char *restart_service_prop;
+ char *restart_protocol;
+ char *restart_machine;
+ Bool run_local;
+ Bool is_manager;
+ Bool ran_manager = 0;
for(cl = ListFirst(PendingList); cl; cl = ListNext(cl)) {
c = (PendingClient *)cl->thing;
- if (app_resources.verbose) {
+ if (verbose) {
printf("Restarting id '%s'...\n", c->clientId);
printf("Host = %s\n", c->clientHostname);
}
@@ -155,29 +185,38 @@ restart_everything()
env = NULL;
program=NULL;
args=NULL;
+ restart_service_prop=NULL;
+
+ is_manager = 0;
for(pl = ListFirst(c->props); pl; pl = ListNext(pl)) {
- prop = (PendingProp *)pl->thing;
- if(!strcmp(prop->name, "Program")) {
+ prop = (Prop *)pl->thing;
+ if(!strcmp(prop->name, SmProgram)) {
+ vl = ListFirst(prop->values);
+ if(vl) program = ((PropValue *)vl->thing)->value;
+ if (CheckIsManager (program))
+ is_manager = 1;
+ } else if(!strcmp(prop->name, SmCurrentDirectory)) {
vl = ListFirst(prop->values);
- if(vl) program = ((PendingValue *)vl->thing)->value;
- } else if(!strcmp(prop->name, "CurrentDirectory")) {
+ if(vl) cwd = ((PropValue *)vl->thing)->value;
+ } else if(!strcmp(prop->name, "_XC_RestartService")) {
vl = ListFirst(prop->values);
- if(vl) cwd = ((PendingValue *)vl->thing)->value;
- } else if(!strcmp(prop->name, "RestartCommand")) {
+ if(vl) restart_service_prop =
+ ((PropValue *)vl->thing)->value;
+ } else if(!strcmp(prop->name, SmRestartCommand)) {
cnt = ListCount(prop->values);
- args = (char **)malloc((cnt+1) * sizeof(char *));
+ args = (char **)XtMalloc((cnt+1) * sizeof(char *));
pp = args;
for(vl = ListFirst(prop->values); vl; vl = ListNext(vl)) {
- *pp++ = ((PendingValue *)vl->thing)->value;
+ *pp++ = ((PropValue *)vl->thing)->value;
}
*pp = NULL;
- } else if(!strcmp(prop->name, "Environment")) {
+ } else if(!strcmp(prop->name, SmEnvironment)) {
cnt = ListCount(prop->values);
- env = (char **)malloc((cnt+3+1) * sizeof(char *));
+ env = (char **)XtMalloc((cnt+3+1) * sizeof(char *));
pp = env;
for(vl = ListFirst(prop->values); vl; vl = ListNext(vl)) {
- p = ((PendingValue *)vl->thing)->value;
+ p = ((PropValue *)vl->thing)->value;
if((display_env && strbw(p, "DISPLAY="))
|| (session_env && strbw(p, "SESSION_MANAGER="))
|| (audio_env && strbw(p, "AUDIOSERVER="))
@@ -192,29 +231,67 @@ restart_everything()
}
if(program && args) {
- if (app_resources.verbose) {
+ char logtext[256];
+
+ if ((flag == RESTART_MANAGERS && !is_manager) ||
+ (flag == RESTART_REST_OF_CLIENTS && is_manager))
+ {
+ if(args) XtFree((char *)args);
+ if(env) XtFree((char *)env);
+ continue;
+ }
+
+ if (flag == RESTART_MANAGERS && is_manager)
+ ran_manager = 1;
+
+ if (verbose) {
printf("\t%s\n", program);
printf("\t");
for(pp = args; *pp; pp++) printf("%s ", *pp);
printf("\n");
}
- if (strncmp(c->clientHostname, "tcp/", 4) != 0 &&
- strncmp(c->clientHostname, "decnet/", 7) != 0)
+ GetRestartInfo (restart_service_prop, c->clientHostname,
+ &run_local, &restart_protocol, &restart_machine);
+
+ if (run_local)
{
/*
* The client is being restarted on the local machine.
*/
+ sprintf (logtext, "Restarting locally : ");
+ for (pp = args; *pp; pp++)
+ {
+ strcat (logtext, *pp);
+ strcat (logtext, " ");
+ }
+
+ strcat (logtext, "\n");
+ add_log_text (logtext);
+
switch(fork()) {
case -1:
- perror("fork");
+ sprintf (logtext,
+ "%s: Can't fork() %s", Argv[0], program);
+ add_log_text (logtext);
+ perror (logtext);
break;
case 0: /* kid */
chdir(cwd);
if(env) environ = env;
execvp(program, args);
- perror("execve");
+ sprintf (logtext, "%s: Can't execvp() %s",
+ Argv[0], program);
+ perror (logtext);
+ /*
+ * TODO : We would like to send this log information to the
+ * log window in the parent. This would require opening
+ * a pipe between the parent and child. The child would
+ * set close-on-exec. If the exec succeeds, the pipe will
+ * be closed. If it fails, the child can write a message
+ * to the parent.
+ */
_exit(255);
default: /* parent */
break;
@@ -236,19 +313,314 @@ restart_everything()
if (env == NULL)
env= &no_env;
#endif
- remote_start (c->clientHostname, program, args, cwd, env,
+ sprintf (logtext, "Restarting remotely on %s : ",
+ restart_machine);
+ for (pp = args; *pp; pp++)
+ {
+ strcat (logtext, *pp);
+ strcat (logtext, " ");
+ }
+ strcat (logtext, "\n");
+ add_log_text (logtext);
+
+ remote_start (restart_protocol, restart_machine,
+ program, args, cwd, env,
non_local_display_env, non_local_session_env);
}
+
+ if (restart_protocol)
+ XtFree (restart_protocol);
+
+ if (restart_machine)
+ XtFree (restart_machine);
+
} else {
fprintf(stderr, "Can't restart ID '%s': no program or no args\n",
c->clientId);
}
- if(args) free((char *)args);
- if(env) free((char *)env);
+ if(args) XtFree((char *)args);
+ if(env) XtFree((char *)env);
+ }
+
+ if (flag == RESTART_MANAGERS && !ran_manager)
+ return (0);
+ else
+ return (1);
+}
+
+
+
+/*
+ * Clone a client
+ */
+
+void
+Clone (client, useSavedState)
+
+ClientRec *client;
+Bool useSavedState;
+
+{
+ char *cwd;
+ char *program;
+ char **args;
+ char **env;
+ char **pp;
+ extern char **environ;
+ char *p;
+ char *restart_service_prop;
+ char *restart_protocol;
+ char *restart_machine;
+ Bool run_local;
+ List *pl, *pj;
+
+ if (verbose)
+ {
+ printf ("Cloning id '%s', useSavedState = %d...\n",
+ client->clientId, useSavedState);
+ printf ("Host = %s\n", client->clientHostname);
+ }
+
+ cwd = ".";
+ env = NULL;
+ program = NULL;
+ args = NULL;
+ restart_service_prop = NULL;
+
+ for (pl = ListFirst (client->props); pl; pl = ListNext (pl))
+ {
+ Prop *pprop = (Prop *) pl->thing;
+ List *vl = ListFirst (pprop->values);
+ PropValue *pval = (PropValue *) vl->thing;
+
+ if (strcmp (pprop->name, SmProgram) == 0)
+ program = (char *) pval->value;
+ else if (strcmp (pprop->name, SmCurrentDirectory) == 0)
+ cwd = (char *) pval->value;
+ else if (strcmp (pprop->name, "_XC_RestartService") == 0)
+ restart_service_prop = (char *) pval->value;
+ else if (
+ (!useSavedState && strcmp (pprop->name, SmCloneCommand) == 0) ||
+ (useSavedState && strcmp (pprop->name, SmRestartCommand) == 0))
+ {
+ args = (char **) XtMalloc (
+ (ListCount (pprop->values) + 1) * sizeof (char *));
+
+ pp = args;
+
+ for (pj = ListFirst (pprop->values); pj; pj = ListNext (pj))
+ {
+ pval = (PropValue *) pj->thing;
+ *pp++ = (char *) pval->value;
+ }
+ *pp = NULL;
+ }
+ else if (strcmp (pprop->name, SmEnvironment) == 0)
+ {
+ env = (char **) XtMalloc (
+ (ListCount (pprop->values) + 3 + 1) * sizeof (char *));
+ pp = env;
+
+ for (pj = ListFirst (pprop->values); pj; pj = ListNext (pj))
+ {
+ pval = (PropValue *) pj->thing;
+ p = (char *) pval->value;
+
+ if ((display_env && strbw (p, "DISPLAY="))
+ || (session_env && strbw (p, "SESSION_MANAGER="))
+ || (audio_env && strbw (p, "AUDIOSERVER=")))
+ continue;
+
+ *pp++ = p;
+ }
+
+ if (display_env)
+ *pp++ = display_env;
+ if (session_env)
+ *pp++ = session_env;
+ if (audio_env)
+ *pp++ = audio_env;
+
+ *pp = NULL;
+ }
+ }
+
+ if (program && args)
+ {
+ if (verbose)
+ {
+ printf("\t%s\n", program);
+ printf("\t");
+ for (pp = args; *pp; pp++)
+ printf ("%s ", *pp);
+ printf("\n");
+ }
+
+ GetRestartInfo (restart_service_prop, client->clientHostname,
+ &run_local, &restart_protocol, &restart_machine);
+
+ if (run_local)
+ {
+ /*
+ * The client is being cloned on the local machine.
+ */
+
+ char msg[256];
+
+ switch(fork()) {
+ case -1:
+ sprintf (msg, "%s: Can't fork() %s", Argv[0], program);
+ add_log_text (msg);
+ perror (msg);
+ break;
+ case 0: /* kid */
+ chdir(cwd);
+ if(env) environ = env;
+ execvp(program, args);
+ sprintf (msg, "%s: Can't execvp() %s", Argv[0], program);
+ perror (msg);
+ /*
+ * TODO : We would like to send this log information to the
+ * log window in the parent. This would require opening
+ * a pipe between the parent and child. The child would
+ * set close-on-exec. If the exec succeeds, the pipe will
+ * be closed. If it fails, the child can write a message
+ * to the parent.
+ */
+ _exit(255);
+ default: /* parent */
+ break;
+ }
+ }
+ else if (!remote_allowed)
+ {
+ fprintf(stderr,
+ "Can't remote clone client ID '%s': only local supported\n",
+ client->clientId);
+ }
+ else
+ {
+ /*
+ * The client is being cloned on a remote machine.
+ */
+
+ remote_start (restart_protocol, restart_machine,
+ program, args, cwd, env,
+ non_local_display_env, non_local_session_env);
+ }
+
+ if (restart_protocol)
+ XtFree (restart_protocol);
+
+ if (restart_machine)
+ XtFree (restart_machine);
+
+ }
+ else
+ {
+ XBell (XtDisplay (topLevel), 0);
+
+ fprintf(stderr, "Can't restart ID '%s': no program or no args\n",
+ client->clientId);
+ }
+
+ if (args)
+ XtFree ((char *)args);
+ if (env)
+ XtFree ((char *)env);
+}
+
+
+
+void
+StartDefaultApps ()
+
+{
+ FILE *f;
+ char *buf, *p, *home, filename[128];
+ int buflen, len;
+
+ /*
+ * First try ~/.xsmstartup, then system.xsm
+ */
+
+ home = (char *) getenv ("HOME");
+ if (!home)
+ home = ".";
+ sprintf (filename, "%s/.xsmstartup", home);
+
+ f = fopen (filename, "r");
+
+ if (!f)
+ {
+ f = fopen (SYSTEM_INIT_FILE, "r");
+ if (!f)
+ {
+ printf ("Could not find default apps file. Make sure you did\n");
+ printf ("a 'make install' in the xsm build directory.\n");
+ exit (1);
+ }
+ }
+
+ buf = NULL;
+ buflen = 0;
+
+ while (getline(&buf, &buflen, f))
+ {
+ char logtext[256];
+
+ if (buf[0] == '!')
+ continue; /* a comment */
+
+ if (p = strchr (buf, '\n'))
+ *p = '\0';
+
+ sprintf (logtext, "Starting locally : %s\n", buf);
+ add_log_text (logtext);
+
+ len = strlen (buf);
+
+ buf[len] = '&';
+ buf[len+1] = '\0';
+
+ /* let the shell parse the stupid args */
+
+ execute_system_command (buf);
+ }
+
+ if (buf)
+ free (buf);
+}
+
+
+
+void
+StartNonSessionAwareApps ()
+
+{
+ char logtext[256];
+ int i;
+
+ for (i = 0; i < non_session_aware_count; i++)
+ {
+ /*
+ * Let the shell parse the stupid args. We need to add an "&"
+ * at the end of the command. We previously allocated an extra
+ * byte for this.
+ */
+
+ sprintf (logtext, "Restarting locally : %s\n",
+ non_session_aware_clients[i]);
+ add_log_text (logtext);
+
+ strcat (non_session_aware_clients[i], "&");
+ execute_system_command (non_session_aware_clients[i]);
+ free ((char *) non_session_aware_clients[i]);
+ }
+
+ if (non_session_aware_clients)
+ {
+ free ((char *) non_session_aware_clients);
+ non_session_aware_clients = NULL;
}
- if(display_env) free(display_env);
- if(session_env) free(session_env);
- if(non_local_display_env) free(non_local_display_env);
- if(non_local_session_env) free(non_local_session_env);
- if(audio_env) free(audio_env);
}
diff --git a/workInProgress/xsm/xsm.h b/workInProgress/xsm/xsm.h
index ae0652eba..f521edca9 100644
--- a/workInProgress/xsm/xsm.h
+++ b/workInProgress/xsm/xsm.h
@@ -1,5 +1,5 @@
-/* $XConsortium: xsm.h,v 1.5 94/04/17 21:15:20 rws Exp $ */
-/* $XFree86: xc/workInProgress/xsm/xsm.h,v 3.1 1994/11/26 12:55:43 dawes Exp $ */
+/* $XConsortium: xsm.h,v 1.36 95/01/03 17:22:47 mor Exp $ */
+/* $XFree86: xc/workInProgress/xsm/xsm.h,v 3.2 1994/11/30 20:52:07 dawes Exp $ */
/******************************************************************************
Copyright (c) 1993 X Consortium
@@ -26,30 +26,19 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
******************************************************************************/
-#include <X11/StringDefs.h>
-#include <X11/Intrinsic.h>
-#include <X11/Xaw/Box.h>
-#include <X11/Xaw/Command.h>
-#include <X11/Xaw/Dialog.h>
-#include <X11/Xaw/Toggle.h>
+#include <X11/Xos.h>
#include <X11/Xfuncs.h>
-#ifndef _POSIX_SOURCE
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
#define _POSIX_SOURCE
-#include <stdio.h>
+#include <limits.h>
#undef _POSIX_SOURCE
-#else
-#include <stdio.h>
-#endif
-#include <X11/Shell.h>
-#include <X11/ICE/ICEutil.h>
-#include <X11/SM/SMlib.h>
-#include <ctype.h>
-#ifndef X_NOT_STDC_ENV
-#include <stdlib.h>
#endif
-#include <setjmp.h>
-#include <limits.h>
-#ifndef MINIX
+#endif /* X_NOT_POSIX */
+#ifndef PATH_MAX
#include <sys/param.h>
#endif
#ifndef PATH_MAX
@@ -58,27 +47,60 @@ in this Software without prior written authorization from the X Consortium.
#else
#define PATH_MAX 1024
#endif
-#endif
-#include <X11/Xos.h>
+#endif /* PATH_MAX */
/* Fix ISC brain damage. When using gcc fdopen isn't declared in <stdio.h>. */
#if defined(__STDC__) && defined(ISC)
extern FILE *fdopen(int, char const *);
#endif
+#ifndef _POSIX_SOURCE
+#define _POSIX_SOURCE
+#include <stdio.h>
+#undef _POSIX_SOURCE
+#else
+#include <stdio.h>
+#endif
+
+#include <ctype.h>
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#endif
+
+#include <X11/StringDefs.h>
+#include <X11/Intrinsic.h>
+
+#include <X11/SM/SMlib.h>
#include "list.h"
-#define MAX_PROPS 50
+/*
+ * Each time the format of the sm's save file changes, bump up
+ * the version.
+ */
+
+#define SAVEFILE_VERSION 3
+
+#define DEFAULT_SESSION_NAME "Default"
+#define FAILSAFE_SESSION_NAME "Fail Safe"
+
+#define RESTART_MANAGERS 1
+#define RESTART_REST_OF_CLIENTS 2
typedef struct _ClientRec {
SmsConn smsConn;
IceConn ice_conn;
char *clientId;
char *clientHostname;
- Bool interactPending;
- int numProps;
- SmProp * props[MAX_PROPS];
- struct _ClientRec *next;
+ List *props;
+ char *discardCommand;
+ char *saveDiscardCommand;
+
+ unsigned int restarted : 1;
+ unsigned int userIssuedCheckpoint : 1;
+ unsigned int restartHint : 2;
+ unsigned int receivedDiscardCommand : 1;
+ unsigned int freeAfterBadSavePopup : 1;
+
} ClientRec;
typedef struct _PendingClient {
@@ -87,24 +109,73 @@ typedef struct _PendingClient {
List *props;
} PendingClient;
-typedef struct _PendingProp {
+typedef struct _Prop {
char *name;
char *type;
List *values;
-} PendingProp;
+} Prop;
-typedef struct _PendingValue {
+typedef struct _PropValue {
XtPointer value;
int length;
-} PendingValue;
+} PropValue;
+
+
+extern int Argc;
+extern char **Argv;
+
+extern char *display_env, *non_local_display_env;
+extern char *session_env, *non_local_session_env;
+extern char *audio_env;
+extern Bool need_to_name_session;
-typedef struct _AppResources {
- Boolean verbose;
- Boolean debug;
-} AppResources;
+extern Bool remote_allowed;
-extern AppResources app_resources;
+extern Bool verbose;
+
+extern char *sm_id;
+
+extern char *networkIds;
+extern char *session_name;
+
+extern List *RunningList;
+extern List *PendingList;
+extern List *RestartAnywayList;
+extern List *RestartImmedList;
+
+extern List *WaitForSaveDoneList;
+extern List *FailedSaveList;
+extern List *WaitForInteractList;
+extern List *WaitForPhase2List;
+
+extern Bool client_info_visible;
+extern Bool client_prop_visible;
+extern Bool client_log_visible;
+extern String *clientListNames;
+extern ClientRec **clientListRecs;
+extern int numClientListNames;
+extern int current_client_selected;
+
+extern Bool shutdownInProgress;
+extern Bool phase2InProgress;
+extern Bool saveInProgress;
+extern Bool shutdownCancelled;
+extern Bool wantShutdown;
+
+extern int sessionNameCount;
+extern String *sessionNamesShort;
+extern String *sessionNamesLong;
+extern Bool *sessionsLocked;
+
+extern int num_clients_in_last_session;
+
+extern char **non_session_aware_clients;
+extern int non_session_aware_count;
+
+extern XtAppContext appContext;
+extern Widget topLevel;
+extern Widget mainWindow;
extern void fprintfhex ();
@@ -114,4 +185,12 @@ extern void fprintfhex ();
extern char *Strstr();
#endif
-extern strbw ();
+/* Fix ISC brain damage. When using gcc fdopen isn't declared in <stdio.h>. */
+#if defined(ISC) && __STDC__
+extern FILE *fdopen(int, char const *);
+#endif
+
+#if defined(sun) && defined(SVR4)
+extern int System();
+#define system(s) System(s)
+#endif