Merge pull request #2763 from naughtont3/tjn-ortedvm-daemonize
dvm: add daemonize and set-sid options
Этот коммит содержится в:
Коммит
cfce565ce9
@ -65,6 +65,7 @@
|
|||||||
#include "opal/util/opal_getcwd.h"
|
#include "opal/util/opal_getcwd.h"
|
||||||
#include "opal/util/show_help.h"
|
#include "opal/util/show_help.h"
|
||||||
#include "opal/util/fd.h"
|
#include "opal/util/fd.h"
|
||||||
|
#include "opal/util/daemon_init.h"
|
||||||
|
|
||||||
#include "opal/version.h"
|
#include "opal/version.h"
|
||||||
#include "opal/runtime/opal.h"
|
#include "opal/runtime/opal.h"
|
||||||
@ -99,6 +100,8 @@ static struct {
|
|||||||
char *report_uri;
|
char *report_uri;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
bool run_as_root;
|
bool run_as_root;
|
||||||
|
bool set_sid;
|
||||||
|
bool daemonize;
|
||||||
} myglobals;
|
} myglobals;
|
||||||
|
|
||||||
static opal_cmd_line_init_t cmd_line_init[] = {
|
static opal_cmd_line_init_t cmd_line_init[] = {
|
||||||
@ -118,6 +121,14 @@ static opal_cmd_line_init_t cmd_line_init[] = {
|
|||||||
&myglobals.prefix, OPAL_CMD_LINE_TYPE_STRING,
|
&myglobals.prefix, OPAL_CMD_LINE_TYPE_STRING,
|
||||||
"Prefix to be used to look for ORTE executables" },
|
"Prefix to be used to look for ORTE executables" },
|
||||||
|
|
||||||
|
{ "orte_daemonize", '\0', NULL, "daemonize", 0,
|
||||||
|
&myglobals.daemonize, OPAL_CMD_LINE_TYPE_BOOL,
|
||||||
|
"Daemonize the orte-dvm into the background" },
|
||||||
|
|
||||||
|
{ NULL, '\0', NULL, "set-sid", 0,
|
||||||
|
&myglobals.set_sid, OPAL_CMD_LINE_TYPE_BOOL,
|
||||||
|
"Direct the orte-dvm to separate from the current session"},
|
||||||
|
|
||||||
{ "orte_debug_daemons", '\0', "debug-daemons", "debug-daemons", 0,
|
{ "orte_debug_daemons", '\0', "debug-daemons", "debug-daemons", 0,
|
||||||
NULL, OPAL_CMD_LINE_TYPE_BOOL,
|
NULL, OPAL_CMD_LINE_TYPE_BOOL,
|
||||||
"Debug daemons" },
|
"Debug daemons" },
|
||||||
@ -278,6 +289,22 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
orte_launch_environ = opal_argv_copy(environ);
|
orte_launch_environ = opal_argv_copy(environ);
|
||||||
|
|
||||||
|
#if defined(HAVE_SETSID)
|
||||||
|
/* see if we were directed to separate from current session */
|
||||||
|
if (myglobals.set_sid) {
|
||||||
|
setsid();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* detach from controlling terminal
|
||||||
|
* otherwise, remain attached so output can get to us
|
||||||
|
*/
|
||||||
|
if(!orte_debug_flag &&
|
||||||
|
!orte_debug_daemons_flag &&
|
||||||
|
myglobals.daemonize) {
|
||||||
|
opal_daemon_init(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Intialize our Open RTE environment */
|
/* Intialize our Open RTE environment */
|
||||||
if (ORTE_SUCCESS != (rc = orte_init(&argc, &argv, ORTE_PROC_MASTER))) {
|
if (ORTE_SUCCESS != (rc = orte_init(&argc, &argv, ORTE_PROC_MASTER))) {
|
||||||
/* cannot call ORTE_ERROR_LOG as it could be the errmgr
|
/* cannot call ORTE_ERROR_LOG as it could be the errmgr
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user