casd | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
New commits:
commit 82d8dbd1d7821e37d5dee114db1023febdbc97c5
Author: adam stokes <uzr(a)jak.rebo>
Date: Mon Jul 20 14:38:24 2009 -0400
- working on a daemon to track kernel changes on
live system
diff --git a/casd b/casd
new file mode 100755
index 0000000..65f62e0
--- /dev/null
+++ b/casd
@@ -0,0 +1,50 @@
+#!/usr/bin/python
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+
+# casd - daemon watcher for various items.
+
+import os
+import sys
+
+class Daemonize(object):
+ """ daemonize class """
+
+ def startDaemon(self):
+ """ start daemon method """
+
+ try:
+ pid = os.fork()
+ except OSError, e:
+ raise SystemExit("Unable to fork %s" % (e.strerror,))
+
+ import resource
+ maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
+ if (maxfd == resource.RLIM_INFINITY):
+ maxfd = MAXFD
+
+ # close file descriptors
+ for i in range(0, self.maxfd):
+ try:
+ os.close(i)
+ except OSError:
+ pass
+
+ os.open(os.devnull, os.R_RDWR)
+ os.dup2(0,1) # dup stdin to
+ os.dup2(0,2) # stdout, stderr
+
+ def __init__(self):
+ self.workdir = "/"
+ self.maxfd = 1024
+ self.umask = 0