#!/usr/bin/env python

import os
import sys

import gobject

from lib.iomon import *

def daemonize():
    try:
        pid = os.fork()
        if pid > 0:
            sys.exit(0)
    except OSError:
        sys.exit(1)

    os.chdir('/')
    os.setsid()
    os.umask(0)

    try:
        pid = os.fork()
        if pid > 0:
            sys.exit(0)
    except OSError:
        sys.exit(1)

    return

def main():
    daemonize()
    iom = IoMonitor
    iom()
    gobject.MainLoop().run()


if __name__ == '__main__':
    main()

#!/usr/bin/env python

import os
import sys

from lib.iomon import *
from gi.repository import GObject


def fork_process():
    try:
        pid = os.fork()
        if pid > 0:
            sys.exit(0)
    except OSError:
        sys.exit(1)
    return

def daemonize():
    fork_process()

    os.chdir('/')
    os.setsid()
    os.umask(0)

    fork_process()

    return

def main():
    daemonize()
    IoMonitor()
    GObject.MainLoop().run()


if __name__ == '__main__':
    main()

adjust new bindings for gobject