clean up GO and GO/BG
This commit is contained in:
		
							parent
							
								
									fe9bfbf1a0
								
							
						
					
					
						commit
						154db1fb92
					
				| 
						 | 
					@ -93,7 +93,8 @@
 | 
				
			||||||
  (signal-process-group signal (job-proc job)))
 | 
					  (signal-process-group signal (job-proc job)))
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
(define (stop-job job)
 | 
					(define (stop-job job)
 | 
				
			||||||
  (signal-job signal/stop job))
 | 
					  (signal-process-group 
 | 
				
			||||||
 | 
					   (proc:pid (job-proc job)) signal/stop))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define (continue-job job)
 | 
					(define (continue-job job)
 | 
				
			||||||
  (set-job-status! job (make-placeholder))
 | 
					  (set-job-status! job (make-placeholder))
 | 
				
			||||||
| 
						 | 
					@ -245,6 +246,11 @@
 | 
				
			||||||
					  ready stopped
 | 
										  ready stopped
 | 
				
			||||||
					  (cons job new-output)
 | 
										  (cons job new-output)
 | 
				
			||||||
					  waiting-for-input #t))
 | 
										  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
 | 
									     (else
 | 
				
			||||||
				      (error "Unhandled signal" signal)))))
 | 
									      (error "Unhandled signal" signal)))))
 | 
				
			||||||
			     ((status:term-sig status)
 | 
								     ((status:term-sig status)
 | 
				
			||||||
| 
						 | 
					@ -292,42 +298,34 @@
 | 
				
			||||||
(define-syntax go
 | 
					(define-syntax go
 | 
				
			||||||
  (syntax-rules ()
 | 
					  (syntax-rules ()
 | 
				
			||||||
    ((_ epf)
 | 
					    ((_ epf)
 | 
				
			||||||
     (save-tty-excursion
 | 
					     (begin
 | 
				
			||||||
      (current-input-port)
 | 
					       (def-prog-mode)
 | 
				
			||||||
      (lambda ()
 | 
					       (clear)
 | 
				
			||||||
	(def-prog-mode)
 | 
					       (endwin)
 | 
				
			||||||
	(clear)
 | 
					       (obtain-lock paint-lock)
 | 
				
			||||||
	(endwin)
 | 
					       (let ((proc
 | 
				
			||||||
	(restore-initial-tty-info! (current-input-port))
 | 
						      (fork
 | 
				
			||||||
	(drain-tty (current-output-port))
 | 
						       (lambda ()
 | 
				
			||||||
	(obtain-lock paint-lock)
 | 
							 (set-process-group (pid) (pid))
 | 
				
			||||||
	(let ((foreground-pgrp (tty-process-group (current-output-port)))
 | 
							 (set-tty-process-group 
 | 
				
			||||||
	      (proc 
 | 
							  (current-output-port) (pid))
 | 
				
			||||||
	       (fork 
 | 
							 (exec-epf epf)))))
 | 
				
			||||||
		(lambda () 
 | 
						 (job-status 
 | 
				
			||||||
		  (set-process-group (pid) (pid))
 | 
						  (make-job-sans-console (quote epf) proc))
 | 
				
			||||||
		  (set-tty-process-group (current-output-port) (pid))
 | 
						 (set-tty-process-group 
 | 
				
			||||||
		  (exec-epf epf)))))
 | 
						  (current-output-port) (pid))
 | 
				
			||||||
	  (job-status (make-job-sans-console (quote epf) proc))
 | 
						 (display "Press any key to return to Commander S...")
 | 
				
			||||||
	  (set-tty-process-group (current-output-port) foreground-pgrp)
 | 
						 (wait-for-key)
 | 
				
			||||||
	  (display "Press any key to return to Commander S...")
 | 
						 (release-lock paint-lock))))))
 | 
				
			||||||
	  (wait-for-key)
 | 
					 | 
				
			||||||
	  (release-lock paint-lock)))))))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define-syntax go/bg
 | 
					(define-syntax go/bg
 | 
				
			||||||
  (syntax-rules ()
 | 
					  (syntax-rules ()
 | 
				
			||||||
    ((_ epf)
 | 
					    ((_ epf)
 | 
				
			||||||
     (begin
 | 
					 | 
				
			||||||
       (obtain-lock paint-lock)
 | 
					 | 
				
			||||||
       (drain-tty (current-output-port))
 | 
					 | 
				
			||||||
       (set-tty-process-group (current-output-port) (pid))
 | 
					 | 
				
			||||||
       (let ((proc
 | 
					       (let ((proc
 | 
				
			||||||
 	      (fork
 | 
					 	      (fork
 | 
				
			||||||
 	       (lambda ()
 | 
					 	       (lambda ()
 | 
				
			||||||
		 (set-process-group (pid) (pid))
 | 
							 (set-process-group (pid) (pid))
 | 
				
			||||||
 		 (exec-epf epf)))))
 | 
					 		 (exec-epf epf)))))
 | 
				
			||||||
 	 (let ((job (make-job-sans-console (quote epf) proc)))
 | 
					 	 (make-job-sans-console (quote epf) proc)))))
 | 
				
			||||||
	   (release-lock paint-lock)
 | 
					 | 
				
			||||||
 	   job))))))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
;;; EOF
 | 
					;;; EOF
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue