Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r13118]: trunk / rosegarden / scripts / seqscavenger.rb Maximize Restore History

Download this file

seqscavenger.rb    70 lines (48 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/ruby -w
$RG_DIR = "/home/glaurent/rosegarden"
#
# Check for rogue sequencer processes left over after a GUI crash
#
def check_stray_sequencer
processes = `ps alxww`.grep(/rosegarden/)
if (processes.length == 1)
# Check if the lone process is the sequencer
pid, ppid, processName = processes[0].split.values_at(2, 3, 12)
#puts "processName : #{processName} - pid : #{pid} - ppid #{ppid}"
if processName =~ /sequencer/ && ppid.to_i == 1
puts "Found stray sequencer running, pid #{pid} - terminating"
Process::kill "SIGTERM", pid.to_i
end
end
end
#
# Check for core files older than the main exec
#
def check_core_files (path, execname)
begin
rgMainExecMTime = File.stat(path + "/" + execname).mtime
# Remove core files older than binary
obsoleteCoreFiles = (Dir[path + "/core.*"].sort{ |a,b| File.stat(a).mtime <=> File.stat(b).mtime })
mostRecentCoreFile = obsoleteCoreFiles.pop
if (File.stat(mostRecentCoreFile).mtime < rgMainExecMTime)
# it's obsolete too, so put it back in obsoleteCoreFiles
obsoleteCoreFiles << mostRecentCoreFile
end
# obsoleteCoreFiles = Dir["gui/core.*"].find_all { |x| File.stat(x).mtime < rgMainExecMTime }
obsoleteCoreFiles.each do |file|
puts "Found obsolete core file to delete : #{file}"
File.delete file
end
# Remove all but most recent core file
rescue Exception
# No exec, no big deal. We don't care.
end
end
### And now for something completely different...
while true
Dir.chdir $RG_DIR
check_stray_sequencer
check_core_files "gui", "rosegarden"
check_core_files "sequencer", "rosegardensequencer"
sleep 5
end