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.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* 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.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-09-26 21:43:35 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2004-09-26 21:43:35 +04:00
|
|
|
#include "mpi.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/runtime/orte_wait.h"
|
2005-07-04 01:57:43 +04:00
|
|
|
#include "opal/runtime/opal_progress.h"
|
2005-03-22 18:24:45 +03:00
|
|
|
#include "runtime/runtime.h"
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#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
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <unistd.h>
|
2004-10-20 05:03:09 +04:00
|
|
|
#endif
|
2004-09-26 21:43:35 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
2005-03-26 16:09:21 +03:00
|
|
|
static void callback(pid_t pid, int status, void *data)
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
printf("callback for %d, %d\n", pid, status);
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-26 16:09:21 +03:00
|
|
|
int main(int argc, char *argv[])
|
2004-09-26 21:43:35 +04:00
|
|
|
{
|
|
|
|
pid_t pid, ret;
|
|
|
|
int status = -1;
|
|
|
|
|
2005-04-21 23:33:18 +04:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS && OMPI_THREADS_HAVE_DIFFERENT_PIDS
|
|
|
|
printf("test not properly configured when threads have different pids\n");
|
|
|
|
return 77;
|
|
|
|
#endif
|
|
|
|
|
2005-08-29 23:32:46 +04:00
|
|
|
orte_init(true);
|
2004-09-26 21:43:35 +04:00
|
|
|
|
|
|
|
pid = fork();
|
|
|
|
if (pid > 0) {
|
|
|
|
count++;
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("parent launched child #1 PID %d\n", pid);
|
2005-03-22 18:24:45 +03:00
|
|
|
orte_wait_cb(pid, callback, NULL);
|
2004-09-26 21:43:35 +04:00
|
|
|
} else {
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("child pid %d sleeping 10 seconds\n", getpid());
|
2004-09-26 21:43:35 +04:00
|
|
|
sleep(10);
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("pid %d exiting after sleeping 10 seconds\n", getpid());
|
2004-09-26 21:43:35 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
pid = fork();
|
|
|
|
if (pid > 0) {
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("parent launched child #2 PID %d\n", pid);
|
2005-03-22 18:24:45 +03:00
|
|
|
ret = orte_waitpid(pid, &status, 0);
|
2004-09-26 21:43:35 +04:00
|
|
|
printf("pid %d waitpid, status %d\n", ret, status);
|
|
|
|
} else {
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("child pid %d sleeping 5 seconds\n", getpid());
|
2004-09-26 21:43:35 +04:00
|
|
|
sleep(5);
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("pid %d exiting after sleeping 5 seconds\n", getpid());
|
2004-09-26 21:43:35 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
pid = fork();
|
|
|
|
if (pid > 0) {
|
|
|
|
count++;
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("parent launched child #3 PID %d\n", pid);
|
2005-03-22 18:24:45 +03:00
|
|
|
orte_wait_cb(pid, callback, NULL);
|
2004-09-26 21:43:35 +04:00
|
|
|
} else {
|
2005-03-26 16:09:21 +03:00
|
|
|
printf("pid %d exiting after not sleeping at all\n", getpid());
|
2004-09-26 21:43:35 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2005-03-26 16:09:21 +03:00
|
|
|
while (count > 0) {
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress();
|
2005-03-26 16:09:21 +03:00
|
|
|
}
|
2004-09-26 21:43:35 +04:00
|
|
|
|
2005-03-22 18:24:45 +03:00
|
|
|
orte_finalize();
|
2004-09-26 21:43:35 +04:00
|
|
|
return 0;
|
|
|
|
}
|