9 #define LOG(kind, ...) \ 10 GNUNET_log (kind, __VA_ARGS__) 15 #define LOG_DEBUG(...) \ 16 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 84 if ((NULL !=
fn) && (0 != unlink (
fn)))
107 "%d more interrupts needed to send SIGKILL to the child\n",
138 child_death_task_id = NULL;
142 child_death_task_id =
151 terminate_task_id = NULL;
166 for (host = 0; host < nhosts; host++)
167 if (NULL != hosts[host])
199 if (0 != gethostname (hostname, hostname_len))
209 LOG_DEBUG (
"Exiting as `%s' is not the lowest host\n", hostname);
214 LOG_DEBUG (
"Will be executing `%s' on host `%s'\n",
argv2[0], hostname);
217 tmpdir =
getenv (
"TMPDIR");
227 fh = open (
fn, O_CREAT | O_EXCL | O_CLOEXEC,
228 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
233 LOG_DEBUG (
"Lock file already created by other process. Exiting\n");
257 child_death_task_id =
272 int old_errno = errno;
294 printf (
"Need arguments: gnunet-testbed-mpi-spawn <cmd> <cmd_args>");
310 if (NULL == shc_chld)
316 for (cnt = 1; cnt < argc; cnt++)
317 argv2[cnt - 1] = argv[cnt];
const struct GNUNET_SCHEDULER_TaskContext * GNUNET_SCHEDULER_get_task_context(void)
Obtain the reasoning why the current task was started.
static void terminate_task(void *cls)
No special options, use non-blocking read/write operations.
struct GNUNET_OS_Process * GNUNET_OS_start_process_vap(enum GNUNET_OS_InheritStdioFlags std_inheritance, struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, struct GNUNET_DISK_PipeHandle *pipe_stderr, const char *filename, char *const argv[])
Start a process.
void GNUNET_OS_process_destroy(struct GNUNET_OS_Process *proc)
Cleans up process structure contents (OS-dependent) and deallocates it.
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
int GNUNET_OS_process_status(struct GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type, unsigned long *code)
Retrieve the status of a process.
The reading socket is ready.
Context information passed to each scheduler task.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_SCHEDULER_TaskContext tc
Task context of the current task.
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
void GNUNET_SIGNAL_handler_uninstall(struct GNUNET_SIGNAL_Context *ctx)
Uninstall a previously installed signal handler.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
Opaque handle to a host running experiments managed by the testing framework.
enum GNUNET_SCHEDULER_Reason reason
Reason why the task is run now.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
static void destroy_hosts(struct GNUNET_TESTBED_Host **hosts, unsigned int nhosts)
static unsigned long child_exit_code
The return code of the binary.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
Use this option to have all of the standard streams (stdin, stdout and stderror) be inherited...
#define LOG_DEBUG(...)
Debug logging shorthand.
#define GNUNET_OS_get_hostname_max_length()
Get maximum string length returned by gethostname()
static char * fn
Filename of the unique file.
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
GNUNET_OS_ProcessStatusType
Process status types.
static enum GNUNET_OS_ProcessStatusType child_status
The process status of the child.
int main(int argc, char *argv[])
Execution start point.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
The writing-end of a pipe.
The reading-end of a pipe.
static int fh
Handle to the unique file.
static char ** argv2
The arguments including the binary to spawn.
static struct GNUNET_SCHEDULER_Task * terminate_task_id
Task to kill the child.
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
static struct GNUNET_DISK_PipeHandle * sigpipe
Pipe used to communicate shutdown via signal.
struct GNUNET_SIGNAL_Context * GNUNET_SIGNAL_handler_install(int signal, GNUNET_SIGNAL_Handler handler)
Install a signal handler that will be run if the given signal is received.
void GNUNET_TESTBED_host_destroy(struct GNUNET_TESTBED_Host *host)
Destroy a host handle.
static int ret
Global result.
static struct GNUNET_SCHEDULER_Task * child_death_task_id
Task to kill the child.
const char * GNUNET_TESTBED_host_get_hostname(const struct GNUNET_TESTBED_Host *host)
Obtain the host's hostname.
static char * hostname
Our hostname; we give this to all the peers we start.
static struct GNUNET_OS_Process * child
The child process we spawn.
static void shutdown_task(void *cls)
The shutdown task.
static void run(void *cls)
The main scheduler run task.
unsigned int GNUNET_TESTBED_hosts_load_from_loadleveler(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTBED_Host ***hosts)
Loads the set of host allocated by the LoadLeveler Job Scheduler.
Entry in list of pending tasks.
static struct GNUNET_SIGNAL_Context * shc_chld
Child signal handler.
#define LOG(kind,...)
Generic logging shorthand.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
static void sighandler_child_death()
Signal handler called for SIGCHLD.
Handle used to access files (and pipes).
Handle used to manage a pipe.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
static void child_death_task(void *cls)
Task triggered whenever we receive a SIGCHLD (child process died).
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.