Megatest

Check-in [5b3294f8c9]
Login
Overview
Comment:Fixed process killing?
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ezsteps-refactor
Files: files | file ages | folders
SHA1: 5b3294f8c9876377943f3a60ec518089415ed106
User & Date: matt on 2015-04-01 01:19:11
Other Links: branch diff | manifest | tags
Context
2015-04-01
01:20
Merged in ezsteps refactor branch check-in: db2ccc3980 user: matt tags: v1.60
01:19
Fixed process killing? Closed-Leaf check-in: 5b3294f8c9 user: matt tags: ezsteps-refactor
00:08
Added temp test for looking at failed killing of jobs check-in: 9fc571c903 user: matt tags: ezsteps-refactor
Changes

Modified launch.scm from [6a7156d5c7] to [492563d3d0].

400
401
402
403
404
405
406

407
408

409

410
411




412


413
414
415
416
417
418
419
						      (lambda (pid)
							(handle-exceptions
							 exn
							 (begin
							   (debug:print-info 0 "Unable to kill process with pid " pid ", possibly already killed.")
							   (debug:print 0 " message: " ((condition-property-accessor 'exn 'message) exn)))
							 (debug:print 0 "WARNING: Request received to kill job " pid) ;;  " (attempt # " kill-tries ")")

							 (if (process:alive? pid)
							     (begin

							       (process-signal pid signal/int)

							       (thread-sleep! 5)
							       (if (process:process-alive? pid)




								   (process-signal pid signal/kill))))))


						      pids)
						     (tests:test-set-status! run-id test-id "KILLED"  "KILLED" (args:get-arg "-m") #f))
						   (begin
						     (debug:print 0 "ERROR: Nothing to kill, pid1=" pid1 ", pid2=" pid2)
						     (tests:test-set-status! run-id test-id "KILLED"  "FAILED TO KILL" (args:get-arg "-m") #f)
						     )))
					     (mutex-unlock! m)







>
|
|
>
|
>
|
|
>
>
>
>
|
>
>







400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
						      (lambda (pid)
							(handle-exceptions
							 exn
							 (begin
							   (debug:print-info 0 "Unable to kill process with pid " pid ", possibly already killed.")
							   (debug:print 0 " message: " ((condition-property-accessor 'exn 'message) exn)))
							 (debug:print 0 "WARNING: Request received to kill job " pid) ;;  " (attempt # " kill-tries ")")
							 (debug:print-info 0 "Signal mask=" (signal-mask))
							 ;; (if (process:alive? pid)
							 ;;     (begin
							 (map (lambda (pid-num)
								(process-signal pid-num signal/term))
							      (process:get-sub-pids pid))
							 (thread-sleep! 5)
							 ;; (if (process:process-alive? pid)
							 (map (lambda (pid-num)
								(handle-exceptions
								 exn
								 #f
								 (process-signal pid-num signal/kill)))
							      (process:get-sub-pids pid))))
							 ;;    (debug:print-info 0 "not killing process " pid " as it is not alive"))))
						      pids)
						     (tests:test-set-status! run-id test-id "KILLED"  "KILLED" (args:get-arg "-m") #f))
						   (begin
						     (debug:print 0 "ERROR: Nothing to kill, pid1=" pid1 ", pid2=" pid2)
						     (tests:test-set-status! run-id test-id "KILLED"  "FAILED TO KILL" (args:get-arg "-m") #f)
						     )))
					     (mutex-unlock! m)

Modified process.scm from [13bb37a3d1] to [785bc2c6db].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
;;  PURPOSE.
;;======================================================================

;;======================================================================
;; Process convience utils
;;======================================================================


(declare (unit process))
(declare (uses common))

(define (conservative-read port)
  (let loop ((res ""))
    (if (not (eof-object? (peek-char port)))
	(loop (conc res (read-char port)))







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;;  PURPOSE.
;;======================================================================

;;======================================================================
;; Process convience utils
;;======================================================================

(use regex)
(declare (unit process))
(declare (uses common))

(define (conservative-read port)
  (let loop ((res ""))
    (if (not (eof-object? (peek-char port)))
	(loop (conc res (read-char port)))
145
146
147
148
149
150
151












   exn
   ;; possibly pid is a process not a child, look in /proc to see if it is running still
   (file-exists? (conc "/proc/" pid))
   (let-values (((rpid exit-type exit-signal)(process-wait pid #t)))
       (and (number? rpid)
	    (equal? rpid pid)))))
	 



















>
>
>
>
>
>
>
>
>
>
>
>
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
   exn
   ;; possibly pid is a process not a child, look in /proc to see if it is running still
   (file-exists? (conc "/proc/" pid))
   (let-values (((rpid exit-type exit-signal)(process-wait pid #t)))
       (and (number? rpid)
	    (equal? rpid pid)))))
	 
(define (process:get-sub-pids pid)
  (with-input-from-pipe
   (conc "pstree -A -p " pid) ;; | tr 'a-z\\-+`()\\.' ' ' " pid)
   (lambda ()
     (let loop ((inl (read-line))
		(res '()))
       (if (eof-object? inl)
	   (reverse res)
	   (let ((nums (map string->number
			    (string-split-fields "\\d+" inl))))
	     (loop (read-line)
		   (append res nums))))))))