| | 2187 | | spawn_cmd(ac, av) |
| | 2188 | | int ac; |
| | 2189 | | char **av; |
| | 2190 | | { |
| | 2191 | | int *tids = 0; |
| | 2192 | | char *where = 0; |
| | 2193 | | int flags = PvmNoSpawnParent;
|
| | 2194 | | int count = 1; |
| | 2195 | | int i; |
| | 2196 | | int oflg = 0; |
| | 2197 | | int tflg = 0; |
| | 2198 | | int app; |
| | 2199 | | char *ofn = 0; |
| | 2200 | | char *tfn = 0; |
| | 2201 | | struct job *jp, *jp2; |
| | 2202 | | void status_msg(); |
| | 2203 | | void event_dump_hdr(); |
| | 2204 | | void output_dump_hdr(); |
| | 2205 | | int fd; |
| | 2206 | | |
| | 2207 | | while (av[1][0] == '-') { |
| | 2208 | | if (ac < 3) { |
| | 2209 | | fputs("incorrect arg count\n", stdout); |
| | 2210 | | return 1; |
| | 2211 | | } |
| | 2212 | | if (av[1][1] == '~') { |
| | 2213 | | flags |= PvmHostCompl;
|
| | 2214 | | av[1]++; |
| | 2215 | | } |
| | 2216 | | if (av[1][1] == '.' || islower(av[1][1])) { |
| | 2217 | | where = av[1] + 1; |
| | 2218 | | flags |= PvmTaskHost;
|
| | 2219 | | } |
| | 2220 | | if (av[1][1] == ':') |
| | 2221 | | where = av[1] + 1; |
| | 2222 | | if (isupper(av[1][1])) { |
| | 2223 | | where = av[1] + 1; |
| | 2224 | | flags |= PvmTaskArch;
|
| | 2225 | | } |
| | 2226 | | if (av[1][1] == '?') |
| | 2227 | | flags |= PvmTaskDebug;
|
| | 2228 | | if (isdigit(av[1][1])) |
| | 2229 | | count = atoi(av[1] + 1); |
| | 2230 | | if (av[1][1] == '>') { |
| | 2231 | | oflg = 1; |
| | 2232 | | app = 0; |
| | 2233 | | ofn = av[1] + 2; |
| | 2234 | | if (av[1][2] == '>') { |
| | 2235 | | app = 1; |
| | 2236 | | ofn++; |
| | 2237 | | } |
| | 2238 | | if (!*ofn) |
| | 2239 | | ofn = 0; |
| | 2240 | | |
| | 2241 | | |
| | 2242 | | |
| | 2243 | | |
| | 2244 | | } |
| | 2245 | | if (av[1][1] == '@') { |
| | 2246 | | tflg = 1; |
| | 2247 | | tfn = av[1] + 2; |
| | 2248 | | if (!*tfn) |
| | 2249 | | tfn = ""; |
| | 2250 | | } |
| | 2251 | | |
| | 2252 | | if (av[1][1] == '-') { |
| | 2253 | | if ( !strncmp( &(av[1][2]), "host=", 5 ) ) { |
| | 2254 | | where = av[1] + 7; |
| | 2255 | | flags |= PvmTaskHost;
|
| | 2256 | | } |
| | 2257 | | } |
| | 2258 | | av++; |
| | 2259 | | ac--; |
| | 2260 | | } |
| | 2261 | | if (tflg) { |
| | 2262 | | jp2 = job_new(nextjob); |
| | 2263 | | jp2->j_flag |= JOB_TRACE;
|
| | 2264 | | jp2->j_trcid = trc_get_tracer_id(); |
| | 2265 | | jp2->j_trcid->status_msg = status_msg; |
| | 2266 | | if (tfn && !strcmp(tfn,"")) |
| | 2267 | | jp2->j_trcid->event_dump_hdr = event_dump_hdr; |
| | 2268 | | if (oflg && !ofn) ofn = ""; |
| | 2269 | | if (ofn) |
| | 2270 | | jp2->j_trcid->output_dump_hdr = output_dump_hdr; |
| | 2271 | | jp2->j_trcid->event_ctx = pvm_getcontext(); |
| | | | ... |
| | 2283 | | trc_save_host_status_events( jp2->j_trcid ); |
| | 2284 | | if (ofn) { |
| | 2285 | | trc_set_output_file( jp2->j_trcid, ofn ); |
| | 2286 | | if (!trc_open_output_file( jp2->j_trcid )) { |
| | 2287 | | job_free(jp2); |
| | 2288 | | return 1; |
| | 2289 | | } |
| | 2290 | | } |
| | 2291 | | oflg = 0; |
| | 2292 | | } |
| | 2293 | | else { |
| | 2294 | | pvm_setopt(PvmTraceTid, 0);
|
| | 2295 | | |
| | 2296 | | if (oflg) { |
| | 2297 | | pvm_setopt(PvmOutputTid, mytid);
|
| | 2298 | | pvm_setopt(PvmOutputContext, pvm_getcontext());
|
| | 2299 | | pvm_setopt(PvmOutputCode, nextjob);
|
| | 2300 | | jp = job_new(nextjob); |
| | 2301 | | printf("[%d]\n", nextjob - joboffset); |
| | 2302 | | nextjob++; |
| | 2303 | | if (ofn) { |
| | 2304 | | if ( app ) { |
| referenced by returned value | 2305 | | fd = open( ofn, | Problem | | referenced by returned value |
|
| | 2306 | | O_RDWR|O_APPEND|O_CREAT|O_EXCL|O_TRUNC, 0600 );
|
| | 2307 | | } |
| | 2308 | | else { |
| | 2309 | | fd = open( ofn, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600 );
|
| | 2310 | | } |
| referenced by fd | 2311 | | if (fd < 0) { |
| | 2312 | | perror(ofn); |
| | 2313 | | job_free(jp); |
| | 2314 | | return 1; |
| | 2315 | | } |
| | 2316 | | jp->j_ff = fdopen( fd, (app ? "a" : "w") ); |
| | 2317 | | if (!jp->j_ff) { |
| | 2318 | | perror(ofn); |
| | 2319 | | job_free(jp); |
| | 2320 | | return 1; |
| | 2321 | | } |
| | 2322 | | } |
| | 2323 | | } else |
| | 2324 | | pvm_setopt(PvmOutputTid, 0);
|
| | 2325 | | } |
| | 2326 | | |
| | 2327 | | tids = TALLOC(count > 1 ? count : 1, int, "int");
|
| | 2328 | | if ((i = pvm_spawn(av[1], &av[2], flags, where, count, tids)) >= 0) { |
| | 2329 | | if (oflg & !i) |
| | 2330 | | job_free(jp); |
| | | | ... |
| | 2332 | | job_free(jp2); |
| | 2333 | | printf("%d successful\n", i); |
| | 2334 | | for (i = 0; i < count; i++) |
| | 2335 | | if (tids[i] < 0) |
| | 2336 | | printf("%s\n", PVMERRMSG(tids[i]));
|
| | 2337 | | else |
| | 2338 | | printf("t%x\n", tids[i]); |
| | 2339 | | } |
| | 2340 | | MY_FREE(tids);
|
| | 2341 | | return 0; |
| | 2342 | | } |