From 154db1fb9204d3602e79851771dc36a61e792ee1 Mon Sep 17 00:00:00 2001 From: eknauel Date: Wed, 15 Jun 2005 11:42:29 +0000 Subject: [PATCH] clean up GO and GO/BG --- scheme/job.scm | 58 ++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/scheme/job.scm b/scheme/job.scm index 140d1e2..08d2d5c 100644 --- a/scheme/job.scm +++ b/scheme/job.scm @@ -93,7 +93,8 @@ (signal-process-group signal (job-proc job))) (define (stop-job job) - (signal-job signal/stop job)) + (signal-process-group + (proc:pid (job-proc job)) signal/stop)) (define (continue-job job) (set-job-status! job (make-placeholder)) @@ -245,6 +246,11 @@ ready stopped (cons job new-output) waiting-for-input #t)) + ((= signal signal/tstp) + (stop-job job) + (lp (delete job running) + ready (cons job stopped) + new-output waiting-for-input #t)) (else (error "Unhandled signal" signal))))) ((status:term-sig status) @@ -292,42 +298,34 @@ (define-syntax go (syntax-rules () ((_ epf) - (save-tty-excursion - (current-input-port) - (lambda () - (def-prog-mode) - (clear) - (endwin) - (restore-initial-tty-info! (current-input-port)) - (drain-tty (current-output-port)) - (obtain-lock paint-lock) - (let ((foreground-pgrp (tty-process-group (current-output-port))) - (proc - (fork - (lambda () - (set-process-group (pid) (pid)) - (set-tty-process-group (current-output-port) (pid)) - (exec-epf epf))))) - (job-status (make-job-sans-console (quote epf) proc)) - (set-tty-process-group (current-output-port) foreground-pgrp) - (display "Press any key to return to Commander S...") - (wait-for-key) - (release-lock paint-lock))))))) + (begin + (def-prog-mode) + (clear) + (endwin) + (obtain-lock paint-lock) + (let ((proc + (fork + (lambda () + (set-process-group (pid) (pid)) + (set-tty-process-group + (current-output-port) (pid)) + (exec-epf epf))))) + (job-status + (make-job-sans-console (quote epf) proc)) + (set-tty-process-group + (current-output-port) (pid)) + (display "Press any key to return to Commander S...") + (wait-for-key) + (release-lock paint-lock)))))) (define-syntax go/bg (syntax-rules () ((_ epf) - (begin - (obtain-lock paint-lock) - (drain-tty (current-output-port)) - (set-tty-process-group (current-output-port) (pid)) (let ((proc (fork (lambda () (set-process-group (pid) (pid)) (exec-epf epf))))) - (let ((job (make-job-sans-console (quote epf) proc))) - (release-lock paint-lock) - job)))))) + (make-job-sans-console (quote epf) proc))))) -;;; EOF \ No newline at end of file +;;; EOF