D
David Garamond
Example: I need to unmount /usr and /usr2, but currently I can't because
there are some opened files from those partitions. I am going to try
shutting down daemons or killing some processes (or other things), one
at a time, until I can unmount it.
def kill(process, signal)
...
end
# returns false if failed, true if succeeded or already unmounted
def unmount(partition)
...
end
unless unmount("/usr") && unmount("/usr2")
system "/etc/init.d/httpd stop"
system "/etc/init.d/squid stop"
unless unmount("/usr") && unmount("/usr2")
kill("rdiff-backup", :TERM)
sleep 3
unless unmount("/usr") && unmount("/usr2")
kill("rdiff-backup", :KILL)
sleep 3
...
...
end
end
end
I don't like this since I repeat unmount(). I can rewrite this as:
def cond_met
umount("/usr") && unmount("/usr2")
end
unless cond_met
...
unless cond_met
...
...
end
end
But still it's not pretty enough. Any more elegant way?
there are some opened files from those partitions. I am going to try
shutting down daemons or killing some processes (or other things), one
at a time, until I can unmount it.
def kill(process, signal)
...
end
# returns false if failed, true if succeeded or already unmounted
def unmount(partition)
...
end
unless unmount("/usr") && unmount("/usr2")
system "/etc/init.d/httpd stop"
system "/etc/init.d/squid stop"
unless unmount("/usr") && unmount("/usr2")
kill("rdiff-backup", :TERM)
sleep 3
unless unmount("/usr") && unmount("/usr2")
kill("rdiff-backup", :KILL)
sleep 3
...
...
end
end
end
I don't like this since I repeat unmount(). I can rewrite this as:
def cond_met
umount("/usr") && unmount("/usr2")
end
unless cond_met
...
unless cond_met
...
...
end
end
But still it's not pretty enough. Any more elegant way?