1 # Copyright (c) 2010, 2011 Nicira, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
24 def handler(signum, _):
25 raise Exception("Signal handler called with %d" % signum)
30 signal.signal(signal.SIGHUP, handler)
32 parser = argparse.ArgumentParser(
33 description="Open vSwitch daemonization test program for Python.")
34 parser.add_argument("-b", "--bail", action="store_true",
35 help="Exit with an error after daemonize_start().")
37 ovs.daemon.add_args(parser)
38 args = parser.parse_args()
39 ovs.daemon.handle_args(args)
41 ovs.daemon.daemonize_start()
43 sys.stderr.write("%s: exiting after daemonize_start() as requested\n"
44 % ovs.util.PROGRAM_NAME)
46 ovs.daemon.daemonize_complete()
52 if __name__ == '__main__':
56 # Let system.exit() calls complete normally
59 sys.exit(ovs.daemon.RESTART_EXIT_CODE)