- DMC McStas simulation working
SKIPPED: psi/amorstat.c psi/nxamor.c psi/pimotor.c psi/polterwrite.c
This commit is contained in:
@ -34,23 +34,59 @@ set mcwaittime 7
|
||||
#----------------------------------------------------------------------
|
||||
proc mcstasdump {pid} {
|
||||
global mcwaittime
|
||||
if { $pid <= 0} {
|
||||
error "Trying to dump invalid PID: $pid"
|
||||
}
|
||||
clientput "Dumping ..."
|
||||
catch {eval exec /usr/bin/kill -USR2 $pid}
|
||||
wait $mcwaittime
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
# mcstasisrunning has to open a pipe to ps and to read the results of
|
||||
# the ps command. This is because a terminated McStas simulation turns
|
||||
# into a Zombie process which finishes never. This can only be cured
|
||||
# by checking for this in the STAT field of ps's output. According to
|
||||
# the Unix FAQ this is the best solution......
|
||||
#----------------------------------------------------------------------
|
||||
proc readPID {pid} {
|
||||
set f [ open "| /bin/ps -up $pid" r]
|
||||
set pstxt [read $f]
|
||||
close $f
|
||||
return $pstxt
|
||||
}
|
||||
#----------------------------------------------------------------------
|
||||
proc mcstasisrunning {pid} {
|
||||
set ret [catch {eval exec /bin/ps --pid $pid} msg]
|
||||
if {$ret == 0} {
|
||||
return 1
|
||||
} else {
|
||||
return 0;
|
||||
global runningCount runningLast
|
||||
|
||||
if { $pid <= 0} {
|
||||
return 0
|
||||
}
|
||||
set pstxt " "
|
||||
set ret [catch {set pstxt [readPID $pid]} msg]
|
||||
set pslist [split $pstxt "\n"]
|
||||
if { [llength $pslist] < 2} {
|
||||
return 0
|
||||
}
|
||||
set header [lindex $pslist 0]
|
||||
set idx [string first STAT $header]
|
||||
set stat [string trim [string range [lindex $pslist 1] $idx [expr $idx + 4]]]
|
||||
if { [string first Z $stat] >= 0 || [string first T $stat] >= 0} {
|
||||
mccontrol finish
|
||||
return 0
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
proc mcstaskill {pid} {
|
||||
global mcwaittime
|
||||
if { $pid <= 0} {
|
||||
error "Trying to kill invalid PID $pid"
|
||||
}
|
||||
clientput "Killing $pid"
|
||||
catch {eval exec /usr/bin/kill -TERM $pid}
|
||||
wait $mcwaittime
|
||||
# catch {mccontrol finish}
|
||||
wait 10
|
||||
}
|
||||
#-----------------------------------------------------------------------
|
||||
proc mcinstall {} {
|
||||
|
Reference in New Issue
Block a user