     (set (make-local-variable 'gud-last-frame) nil)
     (rdebug-track-mode 1)
     (rdebug-common-initialization)
+
+    ;; Setup exit callback so that the original frame configuration
+    ;; can be restored.
+    (let ((process (get-buffer-process gud-comint-buffer)))
+      (when process
+	(unless (equal rdebug-line-width 120)
+	  (gud-call (format "set width %d" rdebug-line-width)))
+	(set-process-sentinel process
+			      'rdebug-process-sentinel)))
+    
     (when name
       (setq gud-target-name name)
       (setq gud-comint-buffer (current-buffer)))

      (setq gud-last-last-frame gud-last-frame))
    (rename-buffer (format "*rdebug-cmd-%s*" gud-target-name))

    (setcdr (assq 'rdebug-debugger-support-minor-mode minor-mode-map-alist)
            rdebug-debugger-support-minor-mode-map-when-active)
    (when rdebug-many-windows
      (rdebug-setup-windows))))


;; -------------------------------------------------------------------

    (set (make-local-variable 'gud-find-file) 'gud-rdebug-find-file)
    (setq gud-last-last-frame nil)
    (set-process-filter (get-buffer-process (current-buffer)) 'gud-filter)
    (gud-set-buffer)
    ;;

