diff -ruN xterm-166/XTerm.ad xterm-166.david/XTerm.ad
--- xterm-166/XTerm.ad	Sat Jan  5 23:05:02 2002
+++ xterm-166.david/XTerm.ad	Tue Apr  2 05:03:19 2002
@@ -5,7 +5,9 @@
 !
 ! $XFree86: xc/programs/xterm/XTerm.ad,v 3.22 2002/01/05 22:05:02 dickey Exp $
 
-XTerm.JoinSession:False
+! This is nonsense: if the xterm has no session management capabilities,
+! it is useless, and if it does, it is harmful.
+!XTerm.JoinSession:False
 
 *SimpleMenu*BackingStore: NotUseful
 *SimpleMenu*menuLabel.font: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-*
diff -ruN xterm-166/main.c xterm-166.david/main.c
--- xterm-166/main.c	Tue Mar 26 02:46:40 2002
+++ xterm-166.david/main.c	Tue Apr  2 04:58:44 2002
@@ -929,7 +929,7 @@
 {"-class",	NULL,		XrmoptionSkipArg,	(caddr_t) NULL},
 {"-e",		NULL,		XrmoptionSkipLine,	(caddr_t) NULL},
 /* bogus old compatibility stuff for which there are
-   standard XtAppInitialize options now */
+   standard XtOpenApplication options now */
 {"%",		"*tekGeometry",	XrmoptionStickyArg,	(caddr_t) NULL},
 {"#",		".iconGeometry",XrmoptionStickyArg,	(caddr_t) NULL},
 {"-T",		".title",	XrmoptionSepArg,	(caddr_t) NULL},
@@ -1246,6 +1246,26 @@
 
 Bool waiting_for_initial_map;
 
+static void
+die_callback(
+	Widget w,
+	XtPointer client_data GCC_UNUSED,
+	XtPointer call_data GCC_UNUSED)
+{
+  Cleanup(0);
+}
+
+static void
+save_callback(
+	Widget w,
+	XtPointer client_data GCC_UNUSED,
+	XtPointer call_data)
+{
+  XtCheckpointToken token = (XtCheckpointToken) call_data;
+  /* we have nothing to save */
+  token->save_success = True;
+}
+
 /*
  * DeleteWindow(): Action proc to implement ICCCM delete_window.
  */
@@ -1468,7 +1488,7 @@
 	/* Do these first, since we may not be able to open the display */
 	ProgramName = argv[0];
 	TRACE_OPTS(options, optionDescList, XtNumber(optionDescList));
-	TRACE_ARGV("Before XtAppInitialize", argv);
+	TRACE_ARGV("Before XtOpenApplication", argv);
 	if (argc > 1) {
 		int n;
 		int unique = 2;
@@ -1802,11 +1822,12 @@
 #endif
 
 	    XtSetErrorHandler(xt_error);
-	    toplevel = XtAppInitialize (&app_con, my_class,
-					optionDescList,
-					XtNumber(optionDescList),
-					&argc, argv, fallback_resources,
-					NULL, 0);
+	    toplevel = XtOpenApplication (&app_con, my_class,
+					  optionDescList,
+					  XtNumber(optionDescList),
+					  &argc, argv, fallback_resources,
+					  sessionShellWidgetClass,
+					  NULL, 0);
 	    XtSetErrorHandler((XtErrorHandler)0);
 
 	    XtGetApplicationResources(toplevel, (XtPointer) &resource,
@@ -1891,7 +1912,7 @@
 #endif
 
 	/* Parse the rest of the command line */
-	TRACE_ARGV("After XtAppInitialize", argv);
+	TRACE_ARGV("After XtOpenApplication", argv);
 	for (argc--, argv++ ; argc > 0 ; argc--, argv++) {
 	    if(**argv != '-') Syntax (*argv);
 
@@ -1993,6 +2014,9 @@
 #if OPT_TEK4014
 	if (term->misc.tekInhibit)		inhibit |= I_TEK;
 #endif
+
+	XtAddCallback (toplevel, XtNdieCallback, die_callback, NULL);
+	XtAddCallback (toplevel, XtNsaveCallback, save_callback, NULL);
 
 /*
  * Set title and icon name if not specified
diff -ruN xterm-166/misc.c xterm-166.david/misc.c
--- xterm-166/misc.c	Tue Mar 26 02:46:40 2002
+++ xterm-166.david/misc.c	Tue Apr  2 04:36:04 2002
@@ -2040,6 +2040,8 @@
 		}
 	}
 
+	XtVaSetValues (toplevel, XtNjoinSession, False);
+
 	if (screen->pid > 1) {
 	    (void) kill_process_group (screen->pid, SIGHUP);
 	}
diff -ruN xterm-166/trace.c xterm-166.david/trace.c
--- xterm-166/trace.c	Mon Nov  5 03:07:16 2001
+++ xterm-166.david/trace.c	Tue Apr  2 02:07:12 2002
@@ -365,7 +365,7 @@
 	}
     }
 
-    TRACE(("Resource list items that will be ignored by XtAppInitialize:\n"));
+    TRACE(("Resource list items that will be ignored by XtOpenApplication:\n"));
     for (j = 0; j < res_count; j++) {
 	switch (res_array[j].argKind) {
 	case XrmoptionSkipArg:
diff -ruN xterm-166/xterm.dat xterm-166.david/xterm.dat
--- xterm-166/xterm.dat	Sat Dec 30 20:15:47 2000
+++ xterm-166.david/xterm.dat	Tue Apr  2 05:04:51 2002
@@ -5,7 +5,10 @@
 *c132: TRUE
 *scrollBar: on
 *saveLines:	1000
-XTerm.JoinSession:False
+
+! This is nonsense: if the xterm has no session management capabilities,
+! it is useless, and if it does, it is harmful.
+!XTerm.JoinSession:False
 
 ! turn off NumLock support - there is some conflict or problem on VMS
 *numLock: false
