Process.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: euc-jp -*-
00003 
00004 
00005 ##
00006 # \file Process.py
00007 # \brief Process handling functions
00008 # \author Noriaki Ando <n-ando@aist.go.jp> and Shinji Kurihara
00009 #
00010 # Copyright (C) 2010
00011 #     Noriaki Ando
00012 #     Task-intelligence Research Group,
00013 #     Intelligent Systems Research Institute,
00014 #     National Institute of
00015 #         Advanced Industrial Science and Technology (AIST), Japan
00016 #     All rights reserved.
00017 
00018 import os,sys
00019 import traceback
00020 import subprocess
00021 
00022 ##
00023 # @if jp
00024 # @brief プロセスを起動する
00025 # @else
00026 # @brief Launching a process
00027 # @endif
00028 #
00029 # int launch_shell(std::string command)
00030 def launch_shell(command):
00031   args = command.split(" ")
00032 
00033   if sys.platform == "win32":
00034     CREATE_NEW_PROCESS_GROUP = 0x00000200
00035     subproc_args = { 'stdin':     None,
00036                      'stdout':    None,
00037                      'stderr':    None,
00038                      'cwd':       None,
00039                      'close_fds': False,
00040                      'creationflags': CREATE_NEW_PROCESS_GROUP}
00041   else:
00042     subproc_args = { 'stdin':     None,
00043                      'stdout':    None,
00044                      'stderr':    None,
00045                      'cwd':       None,
00046                      'close_fds': False,
00047                      'preexec_fn': os.setsid}
00048 
00049   try:
00050     p = subprocess.Popen(args, **subproc_args)
00051   except OSError:
00052     # fork failed
00053     if sys.version_info[0:3] >= (2, 4, 0):
00054       print traceback.format_exc()
00055     else:
00056       _exc_list = traceback.format_exception(*sys.exc_info())
00057       print "".join(_exc_list)
00058 
00059     return -1
00060   return 0
00061 


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28