2004-09-26 21:43:35 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2008-07-25 19:23:23 +04:00
|
|
|
* Copyright (c) 2004-2008 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-06-12 20:25:26 +04:00
|
|
|
* Copyright (c) 2007 Los Alamos National Security, LLC. All rights
|
|
|
|
* reserved.
|
2008-07-25 19:23:23 +04:00
|
|
|
* Copyright (c) 2008 Institut National de Recherche en Informatique
|
|
|
|
* et Automatique. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-09-26 21:43:35 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/constants.h"
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <assert.h>
|
2008-02-28 04:57:57 +03:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_QUEUE_H
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#endif
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <errno.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <sys/time.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <sys/types.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2008-02-28 04:57:57 +03:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
2004-09-29 22:40:46 +04:00
|
|
|
#include <signal.h>
|
2008-02-28 04:57:57 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <sys/wait.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2008-02-28 22:58:32 +03:00
|
|
|
#include "opal/dss/dss_types.h"
|
2005-07-03 20:06:07 +04:00
|
|
|
#include "opal/class/opal_object.h"
|
2005-07-03 20:22:16 +04:00
|
|
|
#include "opal/class/opal_list.h"
|
2005-07-04 03:09:55 +04:00
|
|
|
#include "opal/event/event.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
#include "opal/threads/condition.h"
|
2008-08-05 19:09:29 +04:00
|
|
|
#include "opal/sys/atomic.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2008-08-05 19:09:29 +04:00
|
|
|
#include "orte/util/show_help.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
#include "orte/runtime/orte_wait.h"
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
|
2008-02-28 22:58:32 +03:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Wait Object Declarations
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
static void message_event_destructor(orte_message_event_t *ev)
|
|
|
|
{
|
Fix a potential, albeit perhaps esoteric, race condition that can occur for fast HNP's, slow orteds, and fast apps. Under those conditions, it is possible for the orted to be caught in its original send of contact info back to the HNP, and thus for the progress stack never to recover back to a high level. In those circumstances, the orted can "hang" when trying to exit.
Add a new function to opal_progress that tells us our recursion depth to support that solution.
Yes, I know this sounds picky, but good ol' Jeff managed to make it happen by driving his cluster near to death...
Also ensure that we declare "failed" for the daemon job when daemons fail instead of the application job. This is important so that orte knows that it cannot use xcast to tell daemons to "exit", nor should it expect all daemons to respond. Otherwise, it is possible to hang.
After lots of testing, decide to default (again) to slurm detecting failed orteds. This proved necessary to avoid rather annoying hangs that were difficult to recover from. There are conditions where slurm will fail to launch all daemons (slurm folks are working on it), and yet again, good ol' Jeff managed to find both of them.
Thanks you Jeff! :-/
This commit was SVN r18611.
2008-06-06 23:36:27 +04:00
|
|
|
if (NULL != ev->ev) {
|
|
|
|
free(ev->ev);
|
|
|
|
}
|
|
|
|
if (NULL != ev->buffer) {
|
|
|
|
OBJ_RELEASE(ev->buffer);
|
|
|
|
}
|
2008-02-29 23:10:31 +03:00
|
|
|
#if OMPI_ENABLE_DEBUG
|
Fix a potential, albeit perhaps esoteric, race condition that can occur for fast HNP's, slow orteds, and fast apps. Under those conditions, it is possible for the orted to be caught in its original send of contact info back to the HNP, and thus for the progress stack never to recover back to a high level. In those circumstances, the orted can "hang" when trying to exit.
Add a new function to opal_progress that tells us our recursion depth to support that solution.
Yes, I know this sounds picky, but good ol' Jeff managed to make it happen by driving his cluster near to death...
Also ensure that we declare "failed" for the daemon job when daemons fail instead of the application job. This is important so that orte knows that it cannot use xcast to tell daemons to "exit", nor should it expect all daemons to respond. Otherwise, it is possible to hang.
After lots of testing, decide to default (again) to slurm detecting failed orteds. This proved necessary to avoid rather annoying hangs that were difficult to recover from. There are conditions where slurm will fail to launch all daemons (slurm folks are working on it), and yet again, good ol' Jeff managed to find both of them.
Thanks you Jeff! :-/
This commit was SVN r18611.
2008-06-06 23:36:27 +04:00
|
|
|
if (NULL != ev->file) {
|
|
|
|
free(ev->file);
|
|
|
|
}
|
2008-02-29 23:10:31 +03:00
|
|
|
#endif
|
2008-02-28 22:58:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void message_event_constructor(orte_message_event_t *ev)
|
|
|
|
{
|
Fix a potential, albeit perhaps esoteric, race condition that can occur for fast HNP's, slow orteds, and fast apps. Under those conditions, it is possible for the orted to be caught in its original send of contact info back to the HNP, and thus for the progress stack never to recover back to a high level. In those circumstances, the orted can "hang" when trying to exit.
Add a new function to opal_progress that tells us our recursion depth to support that solution.
Yes, I know this sounds picky, but good ol' Jeff managed to make it happen by driving his cluster near to death...
Also ensure that we declare "failed" for the daemon job when daemons fail instead of the application job. This is important so that orte knows that it cannot use xcast to tell daemons to "exit", nor should it expect all daemons to respond. Otherwise, it is possible to hang.
After lots of testing, decide to default (again) to slurm detecting failed orteds. This proved necessary to avoid rather annoying hangs that were difficult to recover from. There are conditions where slurm will fail to launch all daemons (slurm folks are working on it), and yet again, good ol' Jeff managed to find both of them.
Thanks you Jeff! :-/
This commit was SVN r18611.
2008-06-06 23:36:27 +04:00
|
|
|
ev->ev = (opal_event_t*)malloc(sizeof(opal_event_t));
|
2008-02-28 22:58:32 +03:00
|
|
|
ev->buffer = OBJ_NEW(opal_buffer_t);
|
Fix a potential, albeit perhaps esoteric, race condition that can occur for fast HNP's, slow orteds, and fast apps. Under those conditions, it is possible for the orted to be caught in its original send of contact info back to the HNP, and thus for the progress stack never to recover back to a high level. In those circumstances, the orted can "hang" when trying to exit.
Add a new function to opal_progress that tells us our recursion depth to support that solution.
Yes, I know this sounds picky, but good ol' Jeff managed to make it happen by driving his cluster near to death...
Also ensure that we declare "failed" for the daemon job when daemons fail instead of the application job. This is important so that orte knows that it cannot use xcast to tell daemons to "exit", nor should it expect all daemons to respond. Otherwise, it is possible to hang.
After lots of testing, decide to default (again) to slurm detecting failed orteds. This proved necessary to avoid rather annoying hangs that were difficult to recover from. There are conditions where slurm will fail to launch all daemons (slurm folks are working on it), and yet again, good ol' Jeff managed to find both of them.
Thanks you Jeff! :-/
This commit was SVN r18611.
2008-06-06 23:36:27 +04:00
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
|
|
ev->file = NULL;
|
|
|
|
#endif
|
2008-08-06 13:42:48 +04:00
|
|
|
}
|
|
|
|
|
2008-02-28 22:58:32 +03:00
|
|
|
OBJ_CLASS_INSTANCE(orte_message_event_t,
|
|
|
|
opal_object_t,
|
|
|
|
message_event_constructor,
|
|
|
|
message_event_destructor);
|
|
|
|
|
2008-12-10 23:40:47 +03:00
|
|
|
static void notify_event_destructor(orte_notify_event_t *ev)
|
|
|
|
{
|
|
|
|
if (NULL != ev->ev) {
|
|
|
|
free(ev->ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void notify_event_constructor(orte_notify_event_t *ev)
|
|
|
|
{
|
|
|
|
ev->ev = (opal_event_t*)malloc(sizeof(opal_event_t));
|
|
|
|
}
|
|
|
|
OBJ_CLASS_INSTANCE(orte_notify_event_t,
|
|
|
|
opal_object_t,
|
|
|
|
notify_event_constructor,
|
|
|
|
notify_event_destructor);
|
|
|
|
|
2008-07-23 20:20:42 +04:00
|
|
|
#ifdef HAVE_WAITPID
|
|
|
|
|
|
|
|
static volatile int cb_enabled = true;
|
|
|
|
static opal_mutex_t mutex;
|
|
|
|
static opal_list_t pending_pids;
|
|
|
|
static opal_list_t registered_cb;
|
2008-02-28 22:58:32 +03:00
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Class Declarations
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
struct blk_waitpid_data_t {
|
2005-07-03 20:06:07 +04:00
|
|
|
opal_object_t super;
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_t *cond;
|
2004-09-26 21:43:35 +04:00
|
|
|
volatile int done;
|
|
|
|
volatile int status;
|
2004-10-27 02:11:03 +04:00
|
|
|
volatile int free;
|
2004-09-26 21:43:35 +04:00
|
|
|
};
|
|
|
|
typedef struct blk_waitpid_data_t blk_waitpid_data_t;
|
|
|
|
|
|
|
|
struct pending_pids_item_t {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t super;
|
2004-09-26 21:43:35 +04:00
|
|
|
pid_t pid;
|
|
|
|
int status;
|
|
|
|
};
|
|
|
|
typedef struct pending_pids_item_t pending_pids_item_t;
|
|
|
|
|
|
|
|
struct registered_cb_item_t {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t super;
|
2004-09-26 21:43:35 +04:00
|
|
|
pid_t pid;
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_fn_t callback;
|
2004-09-26 21:43:35 +04:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
typedef struct registered_cb_item_t registered_cb_item_t;
|
|
|
|
|
2004-12-14 18:47:31 +03:00
|
|
|
struct waitpid_callback_data_t {
|
|
|
|
pid_t pid;
|
|
|
|
int status;
|
|
|
|
int options;
|
|
|
|
pid_t ret;
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_mutex_t mutex;
|
|
|
|
opal_condition_t cond;
|
2004-12-14 18:47:31 +03:00
|
|
|
volatile bool done;
|
|
|
|
};
|
|
|
|
typedef struct waitpid_callback_data_t waitpid_callback_data_t;
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Class Definitions
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
static void
|
2005-07-03 20:06:07 +04:00
|
|
|
blk_waitpid_data_construct(opal_object_t *obj)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
blk_waitpid_data_t *data = (blk_waitpid_data_t*) obj;
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
data->cond = OBJ_NEW(opal_condition_t);
|
2004-09-26 21:43:35 +04:00
|
|
|
data->done = 0;
|
|
|
|
data->status = 0;
|
2004-10-27 02:11:03 +04:00
|
|
|
data->free = 0;
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2005-07-03 20:06:07 +04:00
|
|
|
blk_waitpid_data_destruct(opal_object_t *obj)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
blk_waitpid_data_t *data = (blk_waitpid_data_t*) obj;
|
|
|
|
|
|
|
|
if (NULL != data->cond) OBJ_RELEASE(data->cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-03 20:06:07 +04:00
|
|
|
static OBJ_CLASS_INSTANCE(blk_waitpid_data_t, opal_object_t,
|
2004-09-26 21:43:35 +04:00
|
|
|
blk_waitpid_data_construct,
|
|
|
|
blk_waitpid_data_destruct);
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
static OBJ_CLASS_INSTANCE(pending_pids_item_t, opal_list_item_t, NULL, NULL);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
static OBJ_CLASS_INSTANCE(registered_cb_item_t, opal_list_item_t, NULL, NULL);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2008-08-06 13:42:48 +04:00
|
|
|
static void
|
|
|
|
trigger_event_constructor(orte_trigger_event_t *trig)
|
|
|
|
{
|
2008-10-16 18:21:37 +04:00
|
|
|
trig->name = NULL;
|
2008-08-06 13:42:48 +04:00
|
|
|
trig->channel = -1;
|
|
|
|
opal_atomic_init(&trig->lock, OPAL_ATOMIC_UNLOCKED);
|
|
|
|
}
|
2008-10-16 18:21:37 +04:00
|
|
|
static void
|
|
|
|
trigger_event_destructor(orte_trigger_event_t *trig)
|
|
|
|
{
|
|
|
|
if (NULL != trig->name) {
|
|
|
|
free(trig->name);
|
|
|
|
}
|
|
|
|
}
|
2008-08-06 13:42:48 +04:00
|
|
|
OBJ_CLASS_INSTANCE(orte_trigger_event_t,
|
|
|
|
opal_object_t,
|
|
|
|
trigger_event_constructor,
|
2008-10-16 18:21:37 +04:00
|
|
|
trigger_event_destructor);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Variables
|
|
|
|
*
|
|
|
|
********************************************************************/
|
2005-07-04 03:09:55 +04:00
|
|
|
static struct opal_event handler;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Function Prototypes
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
static void blk_waitpid_cb(pid_t wpid, int status, void *data);
|
|
|
|
static pending_pids_item_t* find_pending_pid(pid_t pid, bool create);
|
|
|
|
static registered_cb_item_t* find_waiting_cb(pid_t pid, bool create);
|
|
|
|
static void do_waitall(int options);
|
2004-10-27 02:11:03 +04:00
|
|
|
static void trigger_callback(registered_cb_item_t *cb,
|
|
|
|
pending_pids_item_t *pending);
|
2005-03-14 23:57:21 +03:00
|
|
|
static int register_callback(pid_t pid, orte_wait_fn_t callback,
|
2004-09-26 21:43:35 +04:00
|
|
|
void *data);
|
2004-10-27 02:11:03 +04:00
|
|
|
static int unregister_callback(pid_t pid);
|
2005-03-14 23:57:21 +03:00
|
|
|
void orte_wait_signal_callback(int fd, short event, void *arg);
|
2004-12-14 18:47:31 +03:00
|
|
|
static pid_t internal_waitpid(pid_t pid, int *status, int options);
|
2005-03-14 23:57:21 +03:00
|
|
|
#if OMPI_THREADS_HAVE_DIFFERENT_PIDS
|
2004-12-14 18:47:31 +03:00
|
|
|
static void internal_waitpid_callback(int fd, short event, void *arg);
|
|
|
|
#endif
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Interface Functions
|
|
|
|
*
|
|
|
|
********************************************************************/
|
2008-07-25 19:23:23 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
orte_wait_disable(void)
|
|
|
|
{
|
|
|
|
opal_event_del(&handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
orte_wait_enable(void)
|
|
|
|
{
|
|
|
|
opal_event_add(&handler, NULL);
|
|
|
|
}
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
int
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_init(void)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&mutex, opal_mutex_t);
|
2005-07-03 20:22:16 +04:00
|
|
|
OBJ_CONSTRUCT(&pending_pids, opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(®istered_cb, opal_list_t);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-07-04 03:09:55 +04:00
|
|
|
opal_event_set(&handler, SIGCHLD, OPAL_EV_SIGNAL|OPAL_EV_PERSIST,
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_signal_callback,
|
|
|
|
&handler);
|
|
|
|
|
2005-07-04 03:09:55 +04:00
|
|
|
opal_event_add(&handler, NULL);
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_finalize(void)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2005-07-04 03:09:55 +04:00
|
|
|
opal_event_del(&handler);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
/* clear out the lists */
|
2005-07-03 20:22:16 +04:00
|
|
|
while (NULL != (item = opal_list_remove_first(&pending_pids))) {
|
2004-09-26 21:43:35 +04:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
2005-07-03 20:22:16 +04:00
|
|
|
while (NULL != (item = opal_list_remove_first(®istered_cb))) {
|
2004-09-26 21:43:35 +04:00
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
OBJ_DESTRUCT(&mutex);
|
|
|
|
OBJ_DESTRUCT(&pending_pids);
|
|
|
|
OBJ_DESTRUCT(®istered_cb);
|
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
int
|
|
|
|
orte_wait_kill(int sig)
|
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t* item;
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2005-03-14 23:57:21 +03:00
|
|
|
do_waitall(0);
|
2005-07-03 20:22:16 +04:00
|
|
|
while (NULL != (item = opal_list_remove_first(®istered_cb))) {
|
2005-03-14 23:57:21 +03:00
|
|
|
registered_cb_item_t *cb = (registered_cb_item_t*)item;
|
|
|
|
pending_pids_item_t *pending = find_pending_pid(cb->pid,false);
|
|
|
|
if(NULL == pending) {
|
|
|
|
int status;
|
|
|
|
kill(cb->pid, sig);
|
|
|
|
waitpid(cb->pid,&status,0);
|
|
|
|
} else {
|
|
|
|
OBJ_RELEASE(pending);
|
|
|
|
}
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2005-03-14 23:57:21 +03:00
|
|
|
}
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
pid_t
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_waitpid(pid_t wpid, int *status, int options)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
pending_pids_item_t *pending = NULL;
|
|
|
|
blk_waitpid_data_t *data = NULL;
|
|
|
|
struct timespec spintime;
|
|
|
|
pid_t ret;
|
|
|
|
|
|
|
|
if ((wpid <= 0) || (0 != (options & WUNTRACED))) {
|
2005-08-15 22:25:35 +04:00
|
|
|
errno = ORTE_ERR_NOT_IMPLEMENTED;
|
2004-09-26 21:43:35 +04:00
|
|
|
return (pid_t) -1;
|
|
|
|
}
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
do_waitall(options);
|
|
|
|
pending = find_pending_pid(wpid, false);
|
|
|
|
if (NULL != pending) {
|
|
|
|
*status = pending->status;
|
|
|
|
ret = pending->pid;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&pending_pids, (opal_list_item_t*) pending);
|
2004-09-26 21:43:35 +04:00
|
|
|
OBJ_RELEASE(pending);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (options & WNOHANG)) {
|
|
|
|
/* blocking - create a blk_waitpid_data_t, register the
|
|
|
|
callback with it, and wait for the trigger. Hold mutex
|
|
|
|
until after we register so that waitpid isn't called before
|
|
|
|
the callback is registered. There is a race condition
|
|
|
|
between starting to sit in the condition_wait and the
|
|
|
|
callback being triggered, so poll for completion on the
|
2005-03-28 19:57:11 +04:00
|
|
|
event just in case. */
|
2004-09-26 21:43:35 +04:00
|
|
|
data = OBJ_NEW(blk_waitpid_data_t);
|
|
|
|
if (NULL == data) {
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
register_callback(wpid, blk_waitpid_cb, data);
|
|
|
|
|
|
|
|
while (0 == data->done) {
|
|
|
|
spintime.tv_sec = 0;
|
|
|
|
spintime.tv_nsec = 1 * 1000 * 1000; /* 1 milliseconds */
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_timedwait(data->cond,
|
2005-03-14 23:57:21 +03:00
|
|
|
&mutex,
|
2004-09-26 21:43:35 +04:00
|
|
|
&spintime);
|
2005-03-28 19:57:11 +04:00
|
|
|
|
|
|
|
/* if we have pthreads and progress threads and we are the
|
2005-07-04 02:45:48 +04:00
|
|
|
event thread, opal_condition_timedwait won't progress
|
2005-03-28 19:57:11 +04:00
|
|
|
anything, so we need to do it. */
|
|
|
|
#if OMPI_HAVE_POSIX_THREADS && OMPI_ENABLE_PROGRESS_THREADS
|
2005-07-04 02:45:48 +04:00
|
|
|
if (opal_using_threads()) {
|
|
|
|
opal_mutex_unlock(&mutex);
|
2005-07-04 03:09:55 +04:00
|
|
|
opal_event_loop(OPAL_EVLOOP_NONBLOCK);
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_mutex_lock(&mutex);
|
2004-10-14 03:08:47 +04:00
|
|
|
}
|
2005-03-28 19:57:11 +04:00
|
|
|
#endif
|
2004-10-27 02:11:03 +04:00
|
|
|
do_waitall(0);
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = wpid;
|
|
|
|
*status = data->status;
|
|
|
|
|
2005-03-28 19:57:11 +04:00
|
|
|
/* Unlock the mutex first, so as to not cause any deadlocks.
|
|
|
|
We aren't going to touch any variables that could cause
|
|
|
|
problems with thread badness, so it's ok to be here without
|
|
|
|
the thread locked. Wich is also the reason we go to done
|
|
|
|
instead of cleanup. */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2005-03-28 19:57:11 +04:00
|
|
|
|
2004-10-27 02:11:03 +04:00
|
|
|
while (0 == data->free) {
|
|
|
|
/* don't free the condition variable until we are positive
|
|
|
|
that the broadcast is done being sent. Otherwise,
|
|
|
|
pthreads gets really unhappy when we pull the rug out
|
|
|
|
from under it. Yes, it's spinning. No, we won't spin
|
2005-03-28 19:57:11 +04:00
|
|
|
for long. */
|
|
|
|
|
2005-07-04 03:09:55 +04:00
|
|
|
if (!OMPI_HAVE_THREAD_SUPPORT || opal_event_progress_thread()) {
|
|
|
|
opal_event_loop(OPAL_EVLOOP_NONBLOCK);
|
2004-10-27 02:11:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
OBJ_RELEASE(data);
|
2005-03-28 19:57:11 +04:00
|
|
|
/* see note above while loop for why we jump to done */
|
2004-10-27 02:11:03 +04:00
|
|
|
goto done;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
/* non-blocking - return what waitpid would */
|
2004-12-14 18:47:31 +03:00
|
|
|
ret = internal_waitpid(wpid, status, options);
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
|
|
|
|
done:
|
2004-09-26 21:43:35 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_cb(pid_t wpid, orte_wait_fn_t callback, void *data)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
if (wpid <= 0) return ORTE_ERR_NOT_IMPLEMENTED;
|
|
|
|
if (NULL == callback) return ORTE_ERR_BAD_PARAM;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
ret = register_callback(wpid, callback, data);
|
2005-03-14 23:57:21 +03:00
|
|
|
do_waitall(0);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-27 02:11:03 +04:00
|
|
|
int
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_cb_cancel(pid_t wpid)
|
2004-10-27 02:11:03 +04:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
if (wpid <= 0) return ORTE_ERR_BAD_PARAM;
|
2004-10-27 02:11:03 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
do_waitall(0);
|
|
|
|
ret = unregister_callback(wpid);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callback from the event library whenever a SIGCHLD is received */
|
2004-09-26 21:43:35 +04:00
|
|
|
void
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_signal_callback(int fd, short event, void *arg)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
2005-07-04 03:09:55 +04:00
|
|
|
struct opal_event *signal = (struct opal_event*) arg;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-07-04 03:09:55 +04:00
|
|
|
if (SIGCHLD != OPAL_EVENT_SIGNAL(signal)) return;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
do_waitall(0);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-27 02:11:03 +04:00
|
|
|
int
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_cb_disable()
|
2004-10-27 02:11:03 +04:00
|
|
|
{
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
do_waitall(0);
|
|
|
|
cb_enabled = false;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-27 02:11:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2005-03-14 23:57:21 +03:00
|
|
|
orte_wait_cb_enable()
|
2004-10-27 02:11:03 +04:00
|
|
|
{
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
cb_enabled = true;
|
|
|
|
do_waitall(0);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-10-27 02:11:03 +04:00
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-27 02:11:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-05 19:09:29 +04:00
|
|
|
int orte_wait_event(opal_event_t **event, orte_trigger_event_t *trig,
|
2008-10-16 18:21:37 +04:00
|
|
|
char *trigger_name,
|
2008-02-28 04:57:57 +03:00
|
|
|
void (*cbfunc)(int, short, void*))
|
|
|
|
{
|
|
|
|
int p[2];
|
|
|
|
|
|
|
|
if (pipe(p) < 0) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_SYS_LIMITS_PIPES);
|
|
|
|
return ORTE_ERR_SYS_LIMITS_PIPES;
|
|
|
|
}
|
|
|
|
|
2008-10-16 18:21:37 +04:00
|
|
|
/* save the trigger name */
|
|
|
|
trig->name = strdup(trigger_name);
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* create the event */
|
|
|
|
*event = (opal_event_t*)malloc(sizeof(opal_event_t));
|
|
|
|
|
|
|
|
/* pass back the write end of the pipe */
|
2008-08-05 19:09:29 +04:00
|
|
|
trig->channel = p[1];
|
2008-02-28 04:57:57 +03:00
|
|
|
|
|
|
|
/* define the event to fire when someone writes to the pipe */
|
|
|
|
opal_event_set(*event, p[0], OPAL_EV_READ, cbfunc, NULL);
|
|
|
|
|
|
|
|
/* Add it to the active events, without a timeout */
|
|
|
|
opal_event_add(*event, NULL);
|
|
|
|
|
|
|
|
/* all done */
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-05 19:09:29 +04:00
|
|
|
void orte_trigger_event(orte_trigger_event_t *trig)
|
2008-02-28 04:57:57 +03:00
|
|
|
{
|
|
|
|
int data=1;
|
|
|
|
|
2008-10-16 18:21:37 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_debug_output,
|
|
|
|
"%s calling %s trigger",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
trig->name));
|
|
|
|
|
|
|
|
/* if we already fired it, don't do it again - this automatically
|
|
|
|
* records that we did fire it
|
|
|
|
*/
|
2008-08-05 19:09:29 +04:00
|
|
|
if (!opal_atomic_trylock(&trig->lock)) { /* returns 1 if already locked */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
write(trig->channel, &data, sizeof(int));
|
2008-08-07 01:53:35 +04:00
|
|
|
close(trig->channel);
|
2008-02-28 04:57:57 +03:00
|
|
|
opal_progress();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Functions
|
|
|
|
*
|
|
|
|
* None of these functions should lock mutex. All but blk_waitpid_cb
|
|
|
|
* should only be called if the mutex is already locked.
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
static void
|
|
|
|
blk_waitpid_cb(pid_t wpid, int status, void *data)
|
|
|
|
{
|
|
|
|
blk_waitpid_data_t *wp_data = (blk_waitpid_data_t*) data;
|
|
|
|
|
|
|
|
wp_data->status = status;
|
|
|
|
wp_data->done = 1;
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_signal(wp_data->cond);
|
2004-10-27 02:11:03 +04:00
|
|
|
wp_data->free = 1;
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -1 will return the first available pid */
|
|
|
|
static pending_pids_item_t *
|
|
|
|
find_pending_pid(pid_t pid, bool create)
|
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item;
|
2004-09-26 21:43:35 +04:00
|
|
|
pending_pids_item_t *pending;
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
for (item = opal_list_get_first(&pending_pids) ;
|
|
|
|
item != opal_list_get_end(&pending_pids) ;
|
|
|
|
item = opal_list_get_next(item)) {
|
2004-09-26 21:43:35 +04:00
|
|
|
pending = (pending_pids_item_t*) item;
|
|
|
|
|
|
|
|
if (pending->pid == pid || -1 == pid) {
|
|
|
|
return pending;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create) {
|
|
|
|
pending = OBJ_NEW(pending_pids_item_t);
|
|
|
|
if (NULL == pending) return NULL;
|
|
|
|
|
|
|
|
pending->pid = pid;
|
|
|
|
pending->status = 0;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&pending_pids, (opal_list_item_t*) pending);
|
2004-09-26 21:43:35 +04:00
|
|
|
return pending;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* pid must be positive */
|
|
|
|
static registered_cb_item_t *
|
|
|
|
find_waiting_cb(pid_t pid, bool create)
|
|
|
|
{
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t *item = NULL;
|
2004-09-26 21:43:35 +04:00
|
|
|
registered_cb_item_t *reg_cb = NULL;
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
for (item = opal_list_get_first(®istered_cb) ;
|
|
|
|
item != opal_list_get_end(®istered_cb) ;
|
|
|
|
item = opal_list_get_next(item)) {
|
2004-09-26 21:43:35 +04:00
|
|
|
reg_cb = (registered_cb_item_t*) item;
|
|
|
|
|
|
|
|
if (reg_cb->pid == pid) {
|
|
|
|
return reg_cb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create) {
|
|
|
|
reg_cb = OBJ_NEW(registered_cb_item_t);
|
|
|
|
if (NULL == reg_cb) return NULL;
|
|
|
|
|
|
|
|
reg_cb->pid = pid;
|
|
|
|
reg_cb->callback = NULL;
|
|
|
|
reg_cb->data = NULL;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(®istered_cb, (opal_list_item_t*) reg_cb);
|
2004-09-26 21:43:35 +04:00
|
|
|
return reg_cb;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_waitall(int options)
|
|
|
|
{
|
2004-10-27 02:11:03 +04:00
|
|
|
if (!cb_enabled) return;
|
2004-09-26 21:43:35 +04:00
|
|
|
while (1) {
|
2005-03-14 23:57:21 +03:00
|
|
|
int status;
|
|
|
|
pid_t ret = internal_waitpid(-1, &status, WNOHANG);
|
|
|
|
pending_pids_item_t *pending;
|
|
|
|
registered_cb_item_t *cb;
|
|
|
|
|
2004-09-26 21:43:35 +04:00
|
|
|
if (-1 == ret && EINTR == errno) continue;
|
|
|
|
if (ret <= 0) break;
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
cb = find_waiting_cb(ret, false);
|
|
|
|
if (NULL == cb) {
|
|
|
|
pending = OBJ_NEW(pending_pids_item_t);
|
|
|
|
pending->pid = ret;
|
|
|
|
pending->status = status;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&pending_pids, &pending->super);
|
2005-03-14 23:57:21 +03:00
|
|
|
} else {
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(®istered_cb, &cb->super);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2005-03-14 23:57:21 +03:00
|
|
|
cb->callback(cb->pid, status, cb->data);
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
2005-03-14 23:57:21 +03:00
|
|
|
OBJ_RELEASE(cb);
|
|
|
|
}
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
trigger_callback(registered_cb_item_t *cb, pending_pids_item_t *pending)
|
|
|
|
{
|
|
|
|
assert(cb->pid == pending->pid);
|
|
|
|
|
2007-06-12 20:25:26 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
2004-09-26 21:43:35 +04:00
|
|
|
cb->callback(cb->pid, pending->status, cb->data);
|
2007-06-12 20:25:26 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(&pending_pids, (opal_list_item_t*) pending);
|
|
|
|
opal_list_remove_item(®istered_cb, (opal_list_item_t*) cb);
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2005-03-14 23:57:21 +03:00
|
|
|
register_callback(pid_t pid, orte_wait_fn_t callback, void *data)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
registered_cb_item_t *reg_cb;
|
|
|
|
pending_pids_item_t *pending;
|
|
|
|
|
|
|
|
/* register the callback */
|
|
|
|
reg_cb = find_waiting_cb(pid, true);
|
2005-08-15 22:25:35 +04:00
|
|
|
if (NULL == reg_cb) return ORTE_ERROR;
|
|
|
|
if (NULL != reg_cb->callback) return ORTE_EXISTS;
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
reg_cb->callback = callback;
|
|
|
|
reg_cb->data = data;
|
|
|
|
|
|
|
|
/* make sure we shouldn't trigger right now */
|
|
|
|
pending = find_pending_pid(pid, false);
|
|
|
|
if (NULL != pending) {
|
|
|
|
trigger_callback(reg_cb, pending);
|
|
|
|
}
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-27 02:11:03 +04:00
|
|
|
static int
|
|
|
|
unregister_callback(pid_t pid)
|
|
|
|
{
|
|
|
|
registered_cb_item_t *reg_cb;
|
|
|
|
|
|
|
|
/* register the callback */
|
|
|
|
reg_cb = find_waiting_cb(pid, false);
|
2005-08-15 22:25:35 +04:00
|
|
|
if (NULL == reg_cb) return ORTE_ERR_BAD_PARAM;
|
2004-10-27 02:11:03 +04:00
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_remove_item(®istered_cb, (opal_list_item_t*) reg_cb);
|
2004-10-27 02:11:03 +04:00
|
|
|
|
2005-08-15 22:25:35 +04:00
|
|
|
return ORTE_SUCCESS;
|
2004-10-27 02:11:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-14 18:47:31 +03:00
|
|
|
|
|
|
|
static pid_t
|
|
|
|
internal_waitpid(pid_t pid, int *status, int options)
|
|
|
|
{
|
2005-03-14 23:57:21 +03:00
|
|
|
#if OMPI_THREADS_HAVE_DIFFERENT_PIDS
|
2004-12-14 18:47:31 +03:00
|
|
|
waitpid_callback_data_t data;
|
|
|
|
struct timeval tv;
|
2005-07-04 03:09:55 +04:00
|
|
|
struct opal_event ev;
|
2004-12-14 18:47:31 +03:00
|
|
|
|
2005-07-04 03:09:55 +04:00
|
|
|
if (opal_event_progress_thread()) {
|
2004-12-14 18:47:31 +03:00
|
|
|
/* I already am the progress thread. no need to event me */
|
|
|
|
return waitpid(pid, status, options);
|
|
|
|
}
|
|
|
|
|
|
|
|
data.done = false;
|
|
|
|
data.pid = pid;
|
|
|
|
data.options = options;
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&(data.mutex), opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&(data.cond), opal_condition_t);
|
2004-12-14 18:47:31 +03:00
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&(data.mutex));
|
2004-12-14 18:47:31 +03:00
|
|
|
|
|
|
|
tv.tv_sec = 0;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
|
2005-07-04 03:09:55 +04:00
|
|
|
opal_evtimer_set(&ev, internal_waitpid_callback, &data);
|
|
|
|
opal_evtimer_add(&ev, &tv);
|
2004-12-14 18:47:31 +03:00
|
|
|
|
|
|
|
while (data.done == false) {
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_wait(&(data.cond), &(data.mutex));
|
2004-12-14 18:47:31 +03:00
|
|
|
}
|
|
|
|
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&(data.mutex));
|
2004-12-14 18:47:31 +03:00
|
|
|
|
|
|
|
OBJ_DESTRUCT(&(data.cond));
|
|
|
|
OBJ_DESTRUCT(&(data.mutex));
|
|
|
|
|
|
|
|
*status = data.status;
|
|
|
|
return data.ret;
|
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
#else
|
2004-12-14 18:47:31 +03:00
|
|
|
return waitpid(pid, status, options);
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
2004-09-26 21:43:35 +04:00
|
|
|
}
|
2004-12-14 18:47:31 +03:00
|
|
|
|
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
#if OMPI_THREADS_HAVE_DIFFERENT_PIDS
|
2004-12-14 18:47:31 +03:00
|
|
|
static void
|
|
|
|
internal_waitpid_callback(int fd, short event, void *arg)
|
|
|
|
{
|
|
|
|
waitpid_callback_data_t *data = (waitpid_callback_data_t*) arg;
|
|
|
|
|
|
|
|
data->ret = waitpid(data->pid, &(data->status), data->options);
|
|
|
|
|
|
|
|
data->done = true;
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_signal(&(data->cond));
|
2004-12-14 18:47:31 +03:00
|
|
|
}
|
|
|
|
#endif
|
2005-07-14 22:05:30 +04:00
|
|
|
|
2007-01-22 08:46:30 +03:00
|
|
|
#elif defined(__WINDOWS__)
|
2005-07-14 22:05:30 +04:00
|
|
|
|
2008-08-06 13:42:48 +04:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Variables
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
|
2008-03-05 15:01:37 +03:00
|
|
|
static volatile int cb_enabled = true;
|
|
|
|
static opal_mutex_t mutex;
|
|
|
|
static opal_list_t pending_pids;
|
|
|
|
static opal_list_t registered_cb;
|
|
|
|
|
2008-08-06 13:42:48 +04:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Class Declarations
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
|
2006-08-23 07:32:36 +04:00
|
|
|
typedef struct {
|
|
|
|
opal_list_item_t super;
|
|
|
|
pid_t pid;
|
|
|
|
HANDLE registered_handle;
|
|
|
|
orte_wait_fn_t callback;
|
|
|
|
void *data;
|
|
|
|
int status;
|
|
|
|
} opal_process_handle_t;
|
|
|
|
|
2008-08-06 13:42:48 +04:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Local Class Definitions
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
|
2006-08-23 07:32:36 +04:00
|
|
|
static void opal_process_handle_construct( opal_object_t* obj )
|
|
|
|
{
|
|
|
|
opal_process_handle_t* handle = (opal_process_handle_t*)obj;
|
|
|
|
|
|
|
|
handle->registered_handle = INVALID_HANDLE_VALUE;
|
|
|
|
handle->pid = 0;
|
|
|
|
handle->callback = NULL;
|
|
|
|
handle->data = NULL;
|
|
|
|
}
|
2008-08-06 13:42:48 +04:00
|
|
|
|
2006-08-23 07:32:36 +04:00
|
|
|
static void opal_process_handle_destruct( opal_object_t* obj )
|
|
|
|
{
|
|
|
|
opal_process_handle_t* handle = (opal_process_handle_t*)obj;
|
|
|
|
|
|
|
|
if( INVALID_HANDLE_VALUE != handle->registered_handle ) {
|
|
|
|
if( 0 == UnregisterWait( handle->registered_handle ) ) {
|
|
|
|
int error = GetLastError();
|
|
|
|
}
|
|
|
|
if( 0 == CloseHandle( handle->registered_handle ) ) {
|
|
|
|
int error = GetLastError();
|
|
|
|
}
|
|
|
|
handle->registered_handle = INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static OBJ_CLASS_INSTANCE( opal_process_handle_t, opal_list_item_t,
|
|
|
|
opal_process_handle_construct, opal_process_handle_destruct );
|
|
|
|
|
2008-10-16 18:21:37 +04:00
|
|
|
static void
|
|
|
|
trigger_event_constructor(orte_trigger_event_t *trig)
|
2008-08-06 13:42:48 +04:00
|
|
|
{
|
2008-10-16 18:21:37 +04:00
|
|
|
trig->name = NULL;
|
2008-08-06 13:42:48 +04:00
|
|
|
trig->channel = -1;
|
|
|
|
opal_atomic_init(&trig->lock, OPAL_ATOMIC_UNLOCKED);
|
|
|
|
}
|
2008-10-16 18:21:37 +04:00
|
|
|
static void
|
|
|
|
trigger_event_destructor(orte_trigger_event_t *trig)
|
|
|
|
{
|
|
|
|
if (NULL != trig->name) {
|
|
|
|
free(trig->name);
|
|
|
|
}
|
|
|
|
}
|
2008-08-06 13:42:48 +04:00
|
|
|
OBJ_CLASS_INSTANCE(orte_trigger_event_t,
|
|
|
|
opal_object_t,
|
|
|
|
trigger_event_constructor,
|
2008-10-16 18:21:37 +04:00
|
|
|
trigger_event_destructor);
|
2008-08-06 13:42:48 +04:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Interface Functions
|
|
|
|
*
|
|
|
|
********************************************************************/
|
|
|
|
|
2005-07-14 22:05:30 +04:00
|
|
|
int
|
2006-08-23 07:32:36 +04:00
|
|
|
orte_wait_init(void)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCT(&mutex, opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(®istered_cb, opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&pending_pids, opal_list_t);
|
2005-09-13 01:45:58 +04:00
|
|
|
return ORTE_SUCCESS;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_finalize(void)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
opal_list_item_t* item;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
|
|
|
|
while (NULL != (item = opal_list_remove_first(&pending_pids))) {
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
while (NULL != (item = opal_list_remove_first(®istered_cb))) {
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
OBJ_DESTRUCT(&mutex);
|
|
|
|
OBJ_DESTRUCT(®istered_cb);
|
|
|
|
OBJ_DESTRUCT(&pending_pids);
|
|
|
|
|
2005-09-13 01:45:58 +04:00
|
|
|
return ORTE_SUCCESS;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
2008-08-05 19:09:29 +04:00
|
|
|
void orte_trigger_event(orte_trigger_event_t *trig)
|
2008-03-05 15:01:37 +03:00
|
|
|
{
|
|
|
|
int data=1;
|
|
|
|
|
2008-10-16 18:21:37 +04:00
|
|
|
OPAL_OUTPUT_VERBOSE((1, orte_debug_output,
|
|
|
|
"%s calling %s trigger",
|
|
|
|
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
trig->name));
|
|
|
|
|
2008-08-05 19:09:29 +04:00
|
|
|
if (!opal_atomic_trylock(&trig->lock)) { /* returns 1 if already locked */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-11 00:13:10 +03:00
|
|
|
send(trig->channel, (const char*)&data, sizeof(int), 0);
|
|
|
|
closesocket(trig->channel);
|
2008-03-05 15:01:37 +03:00
|
|
|
opal_progress();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-23 07:32:36 +04:00
|
|
|
/**
|
|
|
|
* Internal function which find a corresponding process structure
|
|
|
|
* based on the pid. If create is true and the pid does not have a
|
|
|
|
* corresponding process structure, one will be automatically
|
|
|
|
* created and attached to the end of the list.
|
|
|
|
*/
|
|
|
|
static opal_process_handle_t* opal_find_pid_in_list(opal_list_t* list, pid_t pid, bool create)
|
|
|
|
{
|
|
|
|
opal_list_item_t *item = NULL;
|
|
|
|
opal_process_handle_t *handle = NULL;
|
|
|
|
|
|
|
|
for (item = opal_list_get_first(list) ;
|
|
|
|
item != opal_list_get_end(list) ;
|
|
|
|
item = opal_list_get_next(item)) {
|
|
|
|
handle = (opal_process_handle_t*) item;
|
|
|
|
|
|
|
|
if (handle->pid == pid) {
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create) {
|
|
|
|
handle = OBJ_NEW(opal_process_handle_t);
|
|
|
|
if (NULL == handle) return NULL;
|
|
|
|
|
|
|
|
handle->pid = pid;
|
|
|
|
handle->callback = NULL;
|
|
|
|
handle->data = NULL;
|
|
|
|
opal_list_append(list, (opal_list_item_t*)handle);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#define find_pending_pid(PID, CREATE) opal_find_pid_in_list( &pending_pids, (PID), (CREATE) )
|
|
|
|
#define find_pending_cb(PID, CREATE) opal_find_pid_in_list( ®istered_cb, (PID), (CREATE) )
|
|
|
|
|
2005-07-14 22:05:30 +04:00
|
|
|
pid_t
|
|
|
|
orte_waitpid(pid_t wpid, int *status, int options)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
opal_process_handle_t* pending;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the child already gone ?
|
|
|
|
*/
|
|
|
|
pending = find_pending_pid( wpid, false );
|
|
|
|
if( NULL != pending ) {
|
|
|
|
*status = pending->status;
|
|
|
|
opal_list_remove_item( &pending_pids, (opal_list_item_t*)pending );
|
|
|
|
OBJ_RELEASE(pending);
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
return wpid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do we have any registered callback for this particular pid ?
|
|
|
|
*/
|
|
|
|
pending = find_pending_cb( wpid, false );
|
|
|
|
if( NULL != pending ) {
|
|
|
|
opal_list_remove_item( ®istered_cb, (opal_list_item_t*)pending );
|
|
|
|
OBJ_RELEASE( pending );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* No luck so far. Wait until the process complete ...
|
|
|
|
*/
|
|
|
|
if( WAIT_OBJECT_0 == WaitForSingleObject( (HANDLE)wpid, INFINITE ) ) {
|
|
|
|
DWORD exitCode;
|
|
|
|
/* Process completed. Grab the exit value and return. */
|
|
|
|
if( 0 == GetExitCodeProcess( (HANDLE)wpid, &exitCode ) ) {
|
|
|
|
int error = GetLastError();
|
|
|
|
}
|
|
|
|
*status = (int)exitCode;
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
return wpid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CALLBACK trigger_process_detection( void* lpParameter, BOOLEAN TimerOrWaitFired )
|
|
|
|
{
|
|
|
|
opal_process_handle_t* handle = (opal_process_handle_t*)lpParameter;
|
|
|
|
DWORD exitCode;
|
|
|
|
|
|
|
|
opal_list_remove_item( ®istered_cb, (opal_list_item_t*)handle );
|
|
|
|
/**
|
|
|
|
* As this item will never be triggered again, we can safely remove the
|
|
|
|
* registered handle.
|
|
|
|
*/
|
|
|
|
if( 0 == UnregisterWait( handle->registered_handle ) ) {
|
2007-01-25 03:19:02 +03:00
|
|
|
/**
|
|
|
|
* If any callback functions associated with the timer have not completed when
|
|
|
|
* UnregisterWait is called, UnregisterWait unregisters the wait on the callback
|
|
|
|
* functions and fails with the ERROR_IO_PENDING error code. The error code does
|
|
|
|
* not indicate that the function has failed, and the function does not need to
|
|
|
|
* be called again. If your code requires an error code to set only when the
|
|
|
|
* unregister operation has failed, call UnregisterWaitEx instead.
|
|
|
|
*/
|
2006-08-23 07:32:36 +04:00
|
|
|
int error = GetLastError();
|
|
|
|
}
|
|
|
|
handle->registered_handle = INVALID_HANDLE_VALUE;
|
|
|
|
/**
|
|
|
|
* Get the exit code of the process.
|
|
|
|
*/
|
|
|
|
if( 0 == GetExitCodeProcess( (HANDLE)handle->pid, &exitCode ) ) {
|
|
|
|
int error = GetLastError();
|
|
|
|
}
|
|
|
|
handle->status = (int)exitCode;
|
|
|
|
handle->callback(handle->pid, handle->status, handle->data);
|
|
|
|
OBJ_RELEASE( handle );
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb(pid_t wpid, orte_wait_fn_t callback, void *data)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
opal_process_handle_t* handle;
|
|
|
|
|
|
|
|
if (wpid <= 0) return ORTE_ERR_NOT_IMPLEMENTED;
|
|
|
|
if (NULL == callback) return ORTE_ERR_BAD_PARAM;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
handle = find_pending_pid(wpid, false);
|
|
|
|
if( handle != NULL ) {
|
|
|
|
opal_list_remove_item( &pending_pids, (opal_list_item_t*)handle );
|
|
|
|
OBJ_RELEASE(handle);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
handle = find_pending_cb( wpid, true );
|
|
|
|
handle->pid = wpid;
|
|
|
|
handle->callback = callback;
|
|
|
|
handle->data = data;
|
|
|
|
|
2007-06-14 08:35:46 +04:00
|
|
|
if( false == RegisterWaitForSingleObject( &handle->registered_handle, (HANDLE)handle->pid,
|
|
|
|
trigger_process_detection, (void*)handle, INFINITE,
|
|
|
|
WT_EXECUTEONLYONCE | WT_EXECUTELONGFUNCTION) ) {
|
|
|
|
DWORD errcode = GetLastError();
|
|
|
|
char* localbuf = NULL;
|
|
|
|
|
|
|
|
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, errcode, 0, (LPTSTR)&localbuf, 1024, NULL );
|
2008-06-09 18:53:58 +04:00
|
|
|
opal_output( 0, "Failed to initialize the process callback for pid %lu error %s\n",
|
2007-06-14 08:35:46 +04:00
|
|
|
(unsigned long)(handle->pid), localbuf );
|
|
|
|
LocalFree( localbuf );
|
|
|
|
}
|
2006-08-23 07:32:36 +04:00
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
|
|
|
|
return OPAL_SUCCESS;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb_cancel(pid_t wpid)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
opal_process_handle_t* pending;
|
|
|
|
|
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do we have any registered callback for this particular pid ?
|
|
|
|
*/
|
|
|
|
pending = find_pending_cb( wpid, false );
|
|
|
|
if( NULL != pending ) {
|
|
|
|
opal_list_remove_item( ®istered_cb, (opal_list_item_t*)pending );
|
|
|
|
OBJ_RELEASE( pending );
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb_disable(void)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
cb_enabled = false;
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb_enable(void)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
cb_enabled = true;
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
2008-03-05 15:01:37 +03:00
|
|
|
|
2008-08-06 13:42:48 +04:00
|
|
|
int orte_wait_event(opal_event_t **event, orte_trigger_event_t *trig,
|
2008-10-16 18:21:37 +04:00
|
|
|
char *trigger_name,
|
2008-03-05 15:01:37 +03:00
|
|
|
void (*cbfunc)(int, short, void*))
|
|
|
|
{
|
|
|
|
int p[2];
|
|
|
|
|
2008-09-08 18:11:26 +04:00
|
|
|
if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, p) == -1) {
|
|
|
|
return ORTE_ERROR;
|
2008-03-05 15:01:37 +03:00
|
|
|
}
|
|
|
|
|
2008-10-16 18:21:37 +04:00
|
|
|
/* save the trigger name */
|
|
|
|
trig->name = strdup(trigger_name);
|
|
|
|
|
2008-03-05 15:01:37 +03:00
|
|
|
/* create the event */
|
|
|
|
*event = (opal_event_t*)malloc(sizeof(opal_event_t));
|
|
|
|
|
2008-12-11 00:13:10 +03:00
|
|
|
/* setup the trigger and its associated lock */
|
|
|
|
OBJ_CONSTRUCT(trig, orte_trigger_event_t);
|
|
|
|
|
2008-03-05 15:01:37 +03:00
|
|
|
/* pass back the write end of the pipe */
|
2008-08-06 13:42:48 +04:00
|
|
|
trig->channel = p[1];
|
2008-03-05 15:01:37 +03:00
|
|
|
|
|
|
|
/* define the event to fire when someone writes to the pipe */
|
|
|
|
opal_event_set(*event, p[0], OPAL_EV_READ, cbfunc, NULL);
|
|
|
|
|
|
|
|
/* Add it to the active events, without a timeout */
|
|
|
|
opal_event_add(*event, NULL);
|
|
|
|
|
|
|
|
/* all done */
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-14 22:05:30 +04:00
|
|
|
int
|
|
|
|
orte_wait_kill(int sig)
|
|
|
|
{
|
2006-08-23 07:32:36 +04:00
|
|
|
opal_list_item_t* item;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* First pass. For all registered processes not yet triggered, terminate the
|
|
|
|
* process. Once this first pass is done, we will try to cleanup the ressources
|
|
|
|
*/
|
|
|
|
OPAL_THREAD_LOCK(&mutex);
|
|
|
|
|
|
|
|
for (item = opal_list_get_first(®istered_cb) ;
|
|
|
|
item != opal_list_get_end(®istered_cb) ;
|
|
|
|
item = opal_list_get_next(item)) {
|
|
|
|
opal_process_handle_t* handle = (opal_process_handle_t*)item;
|
|
|
|
|
|
|
|
if( 0 == TerminateProcess( (HANDLE)handle->pid, sig ) ) {
|
|
|
|
int error = GetLastError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Give them a chance to complete the kill. */
|
|
|
|
SleepEx( 1000, TRUE );
|
|
|
|
|
|
|
|
/* And now clean all ressources. */
|
|
|
|
while (NULL != (item = opal_list_remove_first(®istered_cb))) {
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
while (NULL != (item = opal_list_remove_first(&pending_pids))) {
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
OPAL_THREAD_UNLOCK(&mutex);
|
|
|
|
return ORTE_SUCCESS;
|
2005-07-14 22:05:30 +04:00
|
|
|
}
|
|
|
|
|
2007-01-18 02:16:52 +03:00
|
|
|
#else /* no waitpid and not windows */
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_init(void) {
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_finalize(void)
|
|
|
|
{
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
pid_t
|
|
|
|
orte_waitpid(pid_t wpid, int *status, int options)
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb(pid_t wpid, orte_wait_fn_t callback, void *data)
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb_cancel(pid_t wpid)
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb_disable(void)
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_cb_enable(void)
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2008-08-05 19:09:29 +04:00
|
|
|
void orte_trigger_event(orte_trigger_event_t *trig)
|
2008-02-28 04:57:57 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
orte_wait_event(opal_event_t **event, int *trig,
|
2008-10-16 18:21:37 +04:00
|
|
|
char *trigger_name,
|
2008-02-28 04:57:57 +03:00
|
|
|
void (*cbfunc)(int, short, void*))
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2007-01-18 02:16:52 +03:00
|
|
|
int
|
|
|
|
orte_wait_kill(int sig)
|
|
|
|
{
|
|
|
|
return ORTE_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2005-07-14 22:05:30 +04:00
|
|
|
#endif
|