1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
34
#include <sys/types.h>
39
#if defined(__STDC__) || defined(__cplusplus)
45
#define uid_t_fmt "%ld"
50
static void delete_hanging_socket __PR__((void));
51
static int wait_until_pvm_runs __PR__((int numhosts));
52
static void usage __PR__((FILE *out));
54
int main __PR__(( int argc, char *argv[]));
57
* start pvm and return when pvm is started
58
* arguments are the number of nodes to be
59
* controlled by start_pvm
63
/*-------------------------------------------------------------------------*/
64
static void delete_hanging_socket()
68
sprintf(socknam, "/tmp/pvmd.%ld", (u_long)getuid());
72
/*-------------------------------------------------------------------------*/
73
static int wait_until_pvm_runs(numhosts)
77
struct pvmhostinfo *hinfo = NULL;
82
sleep(SLEEPTIME); /* give pvm time to enroll local daemon */
86
if ((tid = pvm_mytid()) < 0)
91
fprintf(stderr, "start_pvm: Couldn't enroll to pvm\n");
95
printf("start_pvm: enrolled to local pvmd\n");
102
sleep(numhosts * SLEEPTIME); /* give pvm time to enroll remote daemons */
104
if (!(rc = pvm_config(&nh, &na, &hinfo))) {
105
if (nh == numhosts) {
106
printf("start_pvm: got %d hosts\n", numhosts);
111
/* may be this is useful if problems occur */
115
printf("start_pvm: got %d of %d hosts\n", nh, numhosts);
116
for (i=0; i<nh; i++) {
117
printf("start_pvm: %d %s %s %d\n",
130
fprintf(stderr, "startpvm: Couldn't get all of the %d requested hosts\n",
135
/* start_pvm is not responsible for converting hostfiles */
136
/* so the hostfile is nothing more than a simple parameter */
137
/* that gets passed to pvmd */
138
static void usage(out)
141
fprintf(out, "usage: start_pvm [-h numhosts] pvmd-path [pvmd-parameters ..]\n");
144
/*-------------------------------------------------------------------------*/
157
if (!strcmp(argv[1], "-h")) {
161
numhosts = strtol(argv[1], &s, 10);
171
delete_hanging_socket();
174
_exit(wait_until_pvm_runs(numhosts));
176
execvp(argv[1], &argv[1]);
177
fprintf(stderr, "exec %s failed\n", argv[1]);