~ubuntu-branches/ubuntu/feisty/pvm/feisty

« back to all changes in this revision

Viewing changes to console/cmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-08-09 00:00:40 UTC
  • mfrom: (2.1.5 dapper)
  • Revision ID: james.westby@ubuntu.com-20060809000040-16kh33tmxx2em716
Tags: 3.4.5-7
Build with SHELL=/bin/bash in debian/rules; fixes FTBFS when /bin/sh
isn't bash. (Closes: #379543)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
static char rcsid[] =
3
 
        "$Id: cmds.c,v 1.28 1999/07/08 18:59:39 kohl Exp $";
 
3
        "$Id: cmds.c,v 1.45 2004/01/14 18:46:20 pvmsrc Exp $";
4
4
 
5
5
/*
6
6
 *         PVM version 3.4:  Parallel Virtual Machine System
36
36
 *      PVM console commands.
37
37
 *
38
38
 * $Log: cmds.c,v $
 
39
 * Revision 1.45  2004/01/14 18:46:20  pvmsrc
 
40
 * Added new AIX5* arches.
 
41
 * (Spanker=kohl)
 
42
 *
 
43
 * Revision 1.44  2001/09/26 23:37:22  pvmsrc
 
44
 * Made hd_vmid additions to hostd mirror struct...
 
45
 *      - don't know if this is really necessary, but wtf.
 
46
 * (Spanker=kohl)
 
47
 *
 
48
 * Revision 1.43  2001/09/25 21:18:13  pvmsrc
 
49
 * Minor TMPNAMFUN()/tmpnam() cleanup.
 
50
 *      - moved macro def to pvm3.h, renamed PVMTNPMAN().
 
51
 *      - same for LEN_OF_TMP_NAM -> PVMTMPNAMLEN.
 
52
 *      - mostly a huge waste of time, since *both* tmpnam() & mktemp()
 
53
 *              produce the same "dangerous" warning message in Linux/gcc...
 
54
 *      - damn.
 
55
 * (Spanker=kohl)
 
56
 *
 
57
 * Revision 1.42  2001/08/17 20:18:32  pvmsrc
 
58
 * Added --host= option to spawn command.
 
59
 *      - allows passing IP address in place of host name.
 
60
 *      - used gnu-like syntax at Paul Gray's suggestion... :-)
 
61
 * (Spanker=kohl)
 
62
 *
 
63
 * Revision 1.41  2001/07/30 17:46:08  pvmsrc
 
64
 * O.K., Paul's bug was legit.  Some goofy (Mandrake) Linux passes
 
65
 *      stderr back through rsh...
 
66
 *      - weed out lines with stuff like "/bin/ls: ... No such file..."
 
67
 * (Spanker=kohl)
 
68
 *
 
69
 * Revision 1.40  2001/07/30 16:52:00  pvmsrc
 
70
 * Minor cleanup to auto-diag routine...
 
71
 *      - slightly more solid checking for leftover /tmp/pvmd.* files.
 
72
 *      - inspired by a pseudo-bug report from Paul Gray, could be bogus...
 
73
 *      :-)
 
74
 * (Spanker=kohl)
 
75
 *
 
76
 * Revision 1.39  2001/07/30 16:02:31  pvmsrc
 
77
 * epm -> csm...
 
78
 * (Spanker=kohl)
 
79
 *
 
80
 * Revision 1.38  2001/04/23 14:41:41  pvmsrc
 
81
 * Tweaked spawn_cmd() parsing to allow -:wd working directory spec.
 
82
 *      - i.e. without a host or arch specified...
 
83
 *      - fixed help spawn text.
 
84
 * (Spanker=kohl)
 
85
 *
 
86
 * Revision 1.37  2001/02/02 17:05:50  pvmsrc
 
87
 * Fixed typo in Win32 diagnostic message output.
 
88
 * (Spanker=kohl)
 
89
 *
 
90
 * Revision 1.36  2000/03/29 20:01:40  pvmsrc
 
91
 * Stoopid typo...  :-Q
 
92
 * (Spanker=kohl)
 
93
 *
 
94
 * Revision 1.35  2000/02/18 22:01:42  pvmsrc
 
95
 * Cleaned up Windows side of diagnose_cant_start_pvm()...
 
96
 *      - lose any '\r' at end of rsh output.
 
97
 *      - use "chdir" instead of "pwd" for Windows O.S. check.
 
98
 *      - minor typos...
 
99
 * (Spanker=kohl)
 
100
 *
 
101
 * Revision 1.34  2000/02/15 18:06:20  pvmsrc
 
102
 * Modified jobs_cmd() to dump task ids for traced jobs...
 
103
 *      - can't use output buffers, must use TRC_ID->tevtask_list list.
 
104
 *      - snagged necessary state constants from trclib.h, can't just
 
105
 *              #include it, as it #includes fricking everything...  :-Q
 
106
 * (Spanker=kohl)
 
107
 *
 
108
 * Revision 1.33  2000/02/15 17:06:42  pvmsrc
 
109
 * Added new getopt / setopt console commands.
 
110
 *      - for setting PVM console task's PVM options (like PvmShowTids).
 
111
 * Fixed debug flags in tickle help.
 
112
 * (Spanker=kohl)
 
113
 *
 
114
 * Revision 1.32  2000/02/14 20:30:59  pvmsrc
 
115
 * Lose #define-d RSHCOMMAND usage.
 
116
 *      - use new pvmgetrsh() routine, which checks for PVM_RSH or else
 
117
 *              uses old RSHCOMMAND interface.
 
118
 * (Spanker=kohl)
 
119
 *
 
120
 * Revision 1.31  2000/02/10 22:17:38  pvmsrc
 
121
 * Cleaned up diagnose_cant_start_pvmd() test routine a bunch.
 
122
 *      - replaced gobs of inline code with new do_rsh_cmd() routine.
 
123
 *      - added new check_env_var() routine to sort through extra
 
124
 *              garbage in rsh commands when checking env vars...
 
125
 * (Spanker=kohl)
 
126
 *
 
127
 * Revision 1.30  2000/02/10 20:43:37  pvmsrc
 
128
 * Added checking for new PVM_TMP env var on remote host.
 
129
 *      - in diagnose_cant_start_pvm()...
 
130
 *      - use in place of hard-coded /tmp or \TEMP...
 
131
 * (Spanker=kohl)
 
132
 *
 
133
 * Revision 1.29  2000/01/26 23:34:17  pvmsrc
 
134
 * *** Added Killer Routine of All Time - diagnose_cant_start_pvm() ***
 
135
 * Nearly 800 lines of pure joy!  :-D
 
136
 *      - on "Can't start pvmd" error, tries to rsh to host and checks
 
137
 *              everything from rhosts to $PVM_ROOT to /tmp/pmvd.* crap files.
 
138
 *      - should theoretically work on both Unix and Windows machines,
 
139
 *              for both Unix and Windows remote hosts (tested for Unix :-).
 
140
 *      - with any luck this will cut bug mail in half...  yeah right.
 
141
 * (Spanker=kohl)
 
142
 *
39
143
 * Revision 1.28  1999/07/08 18:59:39  kohl
40
144
 * Fixed "Log" keyword placement.
41
145
 *      - indent with " * " for new CVS.
195
299
#endif
196
300
#include <ctype.h>
197
301
#include <signal.h>
 
302
#include <sys/stat.h>
198
303
#include <pvm3.h>
199
304
#include <pvmtev.h>
200
305
#include "cmd.h"
203
308
#include "bfunc.h"
204
309
#include "job.h"
205
310
 
 
311
#ifndef WIN32
 
312
#include <pwd.h>
 
313
#endif
 
314
 
206
315
#define PVMERRMSG(n)    ((n) <= 0 && (n) > -pvm_nerr \
207
316
                                                ? pvm_errlist[-(n)] : "Unknown Error")
208
317
 
224
333
int delete_cmd();
225
334
int echo_cmd();
226
335
int export_cmd();
 
336
int getopt_cmd();
227
337
int halt_cmd();
228
338
int help_cmd();
229
339
int id_cmd();
246
356
*/
247
357
int reset_cmd();
248
358
int setenv_cmd();
 
359
int setopt_cmd();
249
360
int sig_cmd();
250
361
int spawn_cmd();
251
362
int start_cmd();
272
383
        { "conf",    1, 1, conf_cmd },
273
384
        { "delete",  2, 0, delete_cmd },
274
385
        { "echo",    1, 0, echo_cmd },
275
 
        { "export",    1, 0, export_cmd },
 
386
        { "export",  1, 0, export_cmd },
 
387
        { "getopt",  1, 2, getopt_cmd },
276
388
        { "halt",    1, 1, halt_cmd },
277
389
        { "help",    1, 2, help_cmd },
278
390
        { "id",      1, 1, id_cmd },
296
408
*/
297
409
        { "reset",   1, 4, reset_cmd },
298
410
        { "setenv",  1, 0, setenv_cmd },
 
411
        { "setopt",  3, 3, setopt_cmd },
299
412
        { "sig",     3, 0, sig_cmd },
300
413
        { "spawn",   2, 0, spawn_cmd },
301
414
        { "trace",   1, 0, trace_cmd },
307
420
};
308
421
 
309
422
 
 
423
/* Host descriptor (pieces lifted from pvm3/src/host.h - pvmd stuff) */
 
424
 
 
425
struct hostd {
 
426
        int hd_ref;                                     /* num refs to this struct */
 
427
        int hd_hostpart;                        /* host tid base */
 
428
        char *hd_name;                          /* name */
 
429
        char *hd_arch;                          /* cpu arch class */
 
430
        char *hd_login;                         /* loginname  [used master only] */
 
431
        char *hd_dpath;                         /* daemon executable */
 
432
        char *hd_epath;                         /* task exec search path */
 
433
        char *hd_bpath;                         /* debugger executable */
 
434
        char *hd_wdir;                          /* pvmd working dir */
 
435
        char *hd_sopts;                         /* hoster options */
 
436
        int hd_flag;
 
437
        int hd_dsig;                            /* data signature */
 
438
        int hd_err;                                     /* error code */
 
439
        int hd_mtu;                                     /* max snd/rcv length */
 
440
        /* struct sockaddr_in hd_sad;   /^ UDP address/port */
 
441
        int hd_rxseq;                           /* expected next seq num from host */
 
442
        int hd_txseq;                           /* next tx seq num to host */
 
443
        /* struct pkt *hd_txq;          /^ not-yet-sent packet queue to host */
 
444
        /* struct pkt *hd_opq;          /^ outstanding packets to host */
 
445
        int hd_nop;                                     /* length of opq */
 
446
        /* struct pkt *hd_rxq;          /^ packet reordering queue from host */
 
447
        /* struct pmsg *hd_rxm;         /^ to-us msg reassembly from host */
 
448
        /* struct timeval hd_rtt;       /^ estd round-trip time to host */
 
449
        int hd_speed;                           /* cpu relative speed */
 
450
        /* struct mca *hd_mcas;         /^ from-host mca cache */
 
451
        char *hd_aname;                         /* name to use for network address */
 
452
        char *hd_vmid;                          /* virtual machine id for host */
 
453
};
 
454
 
 
455
 
310
456
freealias(ap)
311
457
        struct alias *ap;
312
458
{
472
618
        int ac;
473
619
        char **av;
474
620
{
 
621
        int diagnose = 0;
475
622
        int cc;
476
623
        int *sv;
477
624
        int i;
486
633
                printf("%d successful\n", cc);
487
634
                fputs("                    HOST     DTID\n", stdout);
488
635
                for (i = 0; i < ac; i++)
489
 
                        if ((cc = sv[i]) < 0)
 
636
                        if ((cc = sv[i]) < 0) {
490
637
                                printf("%24s %8s\n", av[i], PVMERRMSG(cc));
 
638
                                if (cc == PvmCantStart)
 
639
                                        diagnose++;
 
640
                        }
491
641
                        else
492
642
                                printf("%24s %8x\n", av[i], cc);
 
643
 
 
644
                /* Try to Further Diagnose "PvmCantStart" Cases... */
 
645
                /* Otherwise, sure to generate MORE BUG MAIL!!!  :-Q */
 
646
                if ( diagnose ) {
 
647
                        printf( "\nAuto-Diagnosing Failed Hosts...\n" );
 
648
                        for (i = 0; i < ac; i++) {
 
649
                                if (sv[i] == PvmCantStart) {
 
650
                                        printf( "%s...\n", av[i] );
 
651
                                        diagnose_cant_start_pvm( av[i] );
 
652
                                        printf( "\n" );
 
653
                                }
 
654
                        }
 
655
                }
493
656
        }
494
657
        MY_FREE(sv);
495
658
        pvm_config(&nhosts, &narchs, &hostlist);
497
660
}
498
661
 
499
662
 
 
663
diagnose_cant_start_pvm( hostline )
 
664
char *hostline;
 
665
{
 
666
        FILE *fp;
 
667
 
 
668
#ifndef WIN32
 
669
        struct passwd *pw;
 
670
#endif
 
671
 
 
672
        struct hostd hp;
 
673
 
 
674
        struct stat statck;
 
675
 
 
676
        char lhost[1024];
 
677
        char pvmarch[1024];
 
678
        char pvmroot[1024];
 
679
        char pvmtmp[1024];
 
680
        char result[1024];
 
681
        char result2[1024];
 
682
        char tcmd[1024];
 
683
        char tmp[255];
 
684
        char user[1024];
 
685
 
 
686
        int remote_os = -1;
 
687
        int len;
 
688
        int i;
 
689
 
 
690
        /* Extract Raw Host Name from Add Command */
 
691
 
 
692
        if ( parsehost(hostline, &hp) < 0 ) {
 
693
                printf( "Error Parsing Host String!\n" );
 
694
                printf( "Cannot Auto-Diagnose!\n" );
 
695
                return( 0 );
 
696
        }
 
697
 
 
698
        /* Get Local Hostname */
 
699
 
 
700
        gethostname( lhost, 1024 );
 
701
 
 
702
        /* Get Local User */
 
703
 
 
704
#ifndef WIN32
 
705
        if ( (pw = getpwuid( getuid() )) != NULL )
 
706
                strcpy( user, pw->pw_name );
 
707
        else
 
708
                strcpy( user, "<your_user_name>" );
 
709
#else
 
710
        strcpy( user, MyGetUserName() );
 
711
#endif
 
712
 
 
713
        /* Ping / Timeout Test */
 
714
 
 
715
        /*
 
716
         * Maybe later - for now rsh returns "Connection timed out"
 
717
         *
 
718
        printf( "Pinging Host \"%s\"...\n", hp.hd_name );
 
719
 
 
720
        sprintf( tcmd, "ping -c 1 %s 1>%s 2>&1", hp.hd_name, tfile );
 
721
 
 
722
        system( tcmd );
 
723
 
 
724
        fp = fopen( tfile, "r" );
 
725
 
 
726
        if ( fp != NULL ) {
 
727
                while ( fgets( result, 1024, fp ) != NULL ) {
 
728
                        printf( "%s\n", result );
 
729
                }
 
730
                fclose( fp );
 
731
        }
 
732
        else
 
733
                printf( "Ping Command Failed - Test Skipped...\n" );
 
734
 
 
735
        unlink( tfile );
 
736
        */
 
737
 
 
738
        /* Verify Rsh Path */
 
739
 
 
740
        printf( "Verifying Local Path to \"rsh\"...\n" );
 
741
 
 
742
        strcpy( tcmd, pvmgetrsh() );
 
743
 
 
744
        if ( stat( tcmd, &statck ) < 0 ) {
 
745
                printf( "\nError - File %s Not Found!\n", tcmd );
 
746
#ifndef WIN32
 
747
                printf( "Use \"whereis rsh\" or \"which rsh\" to determine\n" );
 
748
                printf( "where \"rsh\" is on your system and modify the\n" );
 
749
                printf( "$PVM_ROOT/conf/$PVM_ARCH.def configuration file\n" );
 
750
#else
 
751
                printf( "Determine the path to the \"rsh\" command on your\n" );
 
752
                printf( "system, and edit %PVM_ROOT%\\conf\\WIN32.def\n" );
 
753
#endif
 
754
                printf( "to adjust the path for the -DRSHCOMMAND=\\\"\\\"\n" );
 
755
                printf( "flag.  Then recompile PVM and your applications.\n" );
 
756
 
 
757
                return( 0 );
 
758
        }
 
759
        else
 
760
                printf( "Rsh found in %s - O.K.\n", tcmd );
 
761
 
 
762
        /* Rsh Test */
 
763
 
 
764
        if ( do_rsh_cmd( &hp, "Testing Rsh/Rhosts Access to",
 
765
                        "echo YES", result, 1024 ) ) {
 
766
 
 
767
                /* check result */
 
768
                if ( !strncmp( result, "YES", 3 ) )
 
769
                        printf( "Rsh/Rhosts Access is O.K.\n" );
 
770
                else {
 
771
                        printf( "\nRsh/Rhosts Access FAILED - \"%s\"\n", result );
 
772
                        printf( "Make sure host %s is up and connected to\n",
 
773
                                        hp.hd_name );
 
774
                        printf( "a network and check its DNS / IP address.\n" );
 
775
                        printf( "Also verify that %s is allowed\n", lhost );
 
776
                        printf( "rsh access on %s\n", hp.hd_name );
 
777
                        printf( "Add this line to the $HOME/.rhosts on %s:\n",
 
778
                                        hp.hd_name );
 
779
                        printf( "%s %s\n", lhost, user );
 
780
 
 
781
                        return( 0 );
 
782
                }
 
783
        }
 
784
        else
 
785
                return( 0 );
 
786
 
 
787
        /* Is Remote Host O.S. Windows or Unix? */
 
788
 
 
789
        if ( do_rsh_cmd( &hp, "Checking O.S. Type (Unix test) on",
 
790
                        "pwd", result, 1024 ) ) {
 
791
 
 
792
                /* Unix-land */
 
793
                if ( result[0] == '/' ) {
 
794
                        printf( "Host %s is Unix-based.\n", hp.hd_name );
 
795
                        remote_os = 0;
 
796
                }
 
797
                else if ( do_rsh_cmd( &hp, "Checking O.S. Type (Win test) on",
 
798
                                "chdir", result2, 1024 ) ) {
 
799
 
 
800
                        /* Windows-land */
 
801
                        len = strlen( result2 );
 
802
                        if ( len >= 3 && result2[0] >= 'A' && result2[0] <= 'Z'
 
803
                                        && result2[1] == ':' && result2[2] == '\\' ) {
 
804
                                printf( "Host %s is Windows-based.\n", hp.hd_name );
 
805
                                remote_os = 1;
 
806
                        }
 
807
                        /* Hmmm... Go Figure. */
 
808
                        else {
 
809
                                len = strlen( result );
 
810
                                for ( i=0 ; i < len - 1 && remote_os < 0 ; i++ ) {
 
811
                                        if ( result[i] == '/' ) {
 
812
                                                printf( "Assuming Host %s to be Unix-based.\n",
 
813
                                                                hp.hd_name );
 
814
                                                remote_os = 0;
 
815
                                        }
 
816
                                        else if ( result[0] == '\\' ) {
 
817
                                                printf(
 
818
                                                        "Assuming Host %s to be Windows-based.\n",
 
819
                                                                hp.hd_name );
 
820
                                                remote_os = 1;
 
821
                                        }
 
822
                                }
 
823
                                if ( remote_os < 0 ) {
 
824
                                        len = strlen( result2 );
 
825
                                        if ( !len ) {
 
826
                                                printf( "Assuming Host %s to be Unix-based.\n",
 
827
                                                                hp.hd_name );
 
828
                                                remote_os = 0;
 
829
                                        }
 
830
                                        else {
 
831
                                                for ( i=0 ; i < len - 1 && remote_os < 0 ;
 
832
                                                                i++ ) {
 
833
                                                        if ( result2[i] == '/' ) {
 
834
                                                                printf(
 
835
                                                                "Assuming Host %s to be Unix-based.\n",
 
836
                                                                                hp.hd_name );
 
837
                                                                remote_os = 0;
 
838
                                                        }
 
839
                                                        else if ( result2[0] == '\\' ) {
 
840
                                                                printf(
 
841
                                                        "Assuming Host %s to be Windows-based.\n",
 
842
                                                                                hp.hd_name );
 
843
                                                                remote_os = 1;
 
844
                                                        }
 
845
                                                }
 
846
                                        }
 
847
                                }
 
848
                                if ( remote_os < 0 ) {
 
849
                                        printf( "Error - Cannot Determine Remote O.S.!\n" );
 
850
                                        printf( "Can't Auto-Diagnose.\n" );
 
851
                                        return( 0 );
 
852
                                }
 
853
                        }
 
854
                }
 
855
        }
 
856
        else
 
857
                return( 0 );
 
858
 
 
859
        /* PVM_ROOT Test */
 
860
 
 
861
        if ( do_rsh_cmd( &hp,
 
862
                        ( remote_os == 0 ) ?
 
863
                                "Checking $PVM_ROOT on" : "Checking %PVM_ROOT% on",
 
864
                        ( remote_os == 0 ) ?
 
865
                                "echo $PVM_ROOT" : "echo %PVM_ROOT%",
 
866
                        result, 1024 ) ) {
 
867
 
 
868
                /* check for undefined variable (Unix) */
 
869
                if ( remote_os == 0 && !check_env_var( "PVM_ROOT", result ) ) {
 
870
                        printf(
 
871
                                "\nThe $PVM_ROOT Environment Variable is Not Set!\n" );
 
872
                        printf( "Use one of the shell *.stub files in\n" );
 
873
                        printf( "the pvm3/lib directory to set up the\n" );
 
874
                        printf( "PVM environment on host %s.\n", hp.hd_name );
 
875
 
 
876
                        return( 0 );
 
877
                }
 
878
                /* check for undefined variable (Windows) */
 
879
                else if ( remote_os == 1 && !strncmp( result, "ECHO", 4 ) ) {
 
880
                        printf(
 
881
                        "\nThe %%PVM_ROOT%% Environment Variable is Not Set!\n" );
 
882
                        printf( "Check your PVM installation on host %s or\n",
 
883
                                hp.hd_name );
 
884
                        printf( "set the %%PVM_ROOT%% environment variable\n" );
 
885
                        printf( "in the C:\\AUTOEXEC.BAT file to point to\n" );
 
886
                        printf( "PVM3.4 directory:\n" );
 
887
                        printf( "set PVM_ROOT = C:\\PVM3.4\n" );
 
888
 
 
889
                        return( 0 );
 
890
                }
 
891
                /* check for bogus relative path (Unix) */
 
892
                else if ( remote_os == 0 && result[0] != '/' ) {
 
893
                        printf( "\nThe value of the $PVM_ROOT environment\n" );
 
894
                        printf( "variable on %s is invalid (\"%s\").\n",
 
895
                                hp.hd_name, result );
 
896
                        printf( "Use the absolute path to the pvm3/ directory.\n" );
 
897
 
 
898
                        return( 0 );
 
899
                }
 
900
                /* check for bogus relative path (Windows) */
 
901
                else if ( remote_os == 1 && ( result[1] != ':'
 
902
                                || result[2] != '\\' ) ) {
 
903
                        printf( "\nThe value of the %%PVM_ROOT%% environment\n" );
 
904
                        printf( "variable on %s is invalid (\"%s\").\n",
 
905
                                hp.hd_name, result );
 
906
                        printf(
 
907
                                "Use the absolute path to the PVM3.4 directory.\n" );
 
908
 
 
909
                        return( 0 );
 
910
                }
 
911
                /* appears to be O.K., fall through to next test */
 
912
                else {
 
913
                        strcpy( pvmroot, result );
 
914
                        printf( "%sPVM_ROOT%s on %s Appears O.K. (\"%s\")\n",
 
915
                                ( remote_os == 0 ) ? "$" : "%",
 
916
                                ( remote_os == 0 ) ? "" : "%",
 
917
                                hp.hd_name, pvmroot );
 
918
                }
 
919
        }
 
920
        else
 
921
                return( 0 );
 
922
 
 
923
        /* Pvmd Script Existence Test (a.k.a. $PVM_ROOT Validity Test) */
 
924
 
 
925
        if ( do_rsh_cmd( &hp, "Verifying Location of PVM Daemon Script on",
 
926
                        ( remote_os == 0 ) ? "\\ls $PVM_ROOT/lib/pvmd"
 
927
                                : "dir /B /L %PVM_ROOT%\\lib\\pvmd.bat",
 
928
                        result, 1024 ) ) {
 
929
 
 
930
                /* expected pvmd script path */
 
931
                if ( remote_os == 0 )
 
932
                        sprintf( tmp, "%s/lib/pvmd", pvmroot );
 
933
                else
 
934
                        sprintf( tmp, "pvmd.bat" );
 
935
                /* check existence of pvmd script */
 
936
                if ( strcmp( result, tmp ) ) {
 
937
                        printf( "\nPVM Daemon Script \"%s\"\n", tmp );
 
938
                        printf( "Was Not Found on %s\n", hp.hd_name );
 
939
                        printf( "Please check the setting of %sPVM_ROOT%s...\n",
 
940
                                ( remote_os == 0 ) ? "$" : "%",
 
941
                                ( remote_os == 0 ) ? "" : "%" );
 
942
 
 
943
                        return( 0 );
 
944
                }
 
945
                else
 
946
                        printf( "PVM Daemon Script Found (\"%s\")\n", tmp );
 
947
        }
 
948
        else
 
949
                return( 0 );
 
950
 
 
951
        /* Determine Remote Host Architecture */
 
952
 
 
953
        if ( do_rsh_cmd( &hp, "Determining PVM Architecture on",
 
954
                        ( remote_os == 0 ) ? "echo $PVM_ARCH" : "echo %PVM_ARCH%",
 
955
                        result, 1024 ) ) {
 
956
 
 
957
                /* check for undefined variable */
 
958
                if ( ( remote_os == 0 && check_env_var( "PVM_ARCH", result ) )
 
959
                                || ( remote_os == 1
 
960
                                        && strncmp( result, "ECHO", 4 ) ) ) {
 
961
                        printf( "%sPVM_ARCH%s on %s set to %s\n",
 
962
                                ( remote_os == 0 ) ? "$" : "%",
 
963
                                ( remote_os == 0 ) ? "" : "%",
 
964
                                hp.hd_name, result );
 
965
                        strcpy( pvmarch, result );
 
966
                }
 
967
                else {
 
968
                        printf( "%sPVM_ARCH%s not set on %s\n",
 
969
                                ( remote_os == 0 ) ? "$" : "%",
 
970
                                ( remote_os == 0 ) ? "" : "%",
 
971
                                hp.hd_name );
 
972
                        if ( remote_os == 1 ) {
 
973
                                printf( "Assuming WIN32.\n" );
 
974
                                strcpy( pvmarch, "WIN32" );
 
975
                        }
 
976
                        else
 
977
                                pvmarch[0] = '\0';
 
978
                }
 
979
        }
 
980
        else
 
981
                return( 0 );
 
982
 
 
983
        /* Manually Determine Remote Host Architecture (Unix Only) */
 
984
 
 
985
        if ( remote_os == 0 && pvmarch[0] == '\0' ) {
 
986
 
 
987
                if ( do_rsh_cmd( &hp,
 
988
                                "Manually Determining PVM Architecture on",
 
989
                                "$PVM_ROOT/lib/pvmgetarch", result, 1024 ) ) {
 
990
 
 
991
                        len = strlen( result );
 
992
                        /* sanity check */
 
993
                        if ( len > 1 ) {
 
994
                                printf( "$PVM_ARCH for %s is %s.\n",
 
995
                                        hp.hd_name, result );
 
996
                                strcpy( pvmarch, result );
 
997
                        }
 
998
                        else {
 
999
                                printf( "Could Not Determine $PVM_ARCH.\n" );
 
1000
                                printf( "Can't Further Auto-Diagnose.\n" );
 
1001
 
 
1002
                                return( 0 );
 
1003
                        }
 
1004
                }
 
1005
                else
 
1006
                        return( 0 );
 
1007
        }
 
1008
 
 
1009
        /* Existence of pvmd3 Executable? */
 
1010
 
 
1011
        if ( remote_os == 0 )
 
1012
                sprintf( tmp, "\\ls $PVM_ROOT/lib/%s/pvmd3", pvmarch );
 
1013
        else
 
1014
                sprintf( tmp, "dir /B /L %%PVM_ROOT%%\\lib\\%s\\pvmd3.exe",
 
1015
                        pvmarch );
 
1016
 
 
1017
        if ( do_rsh_cmd( &hp,
 
1018
                        "Verifying Existence of PVM Daemon Executable on",
 
1019
                        tmp, result, 1024 ) ) {
 
1020
 
 
1021
                /* expected pvmd executable path */
 
1022
                if ( remote_os == 0 )
 
1023
                        sprintf( tmp, "%s/lib/%s/pvmd3", pvmroot, pvmarch );
 
1024
                else
 
1025
                        sprintf( tmp, "pvmd3.exe" );
 
1026
                /* check existence of pvmd executable */
 
1027
                if ( strcmp( result, tmp ) ) {
 
1028
                        printf( "\nPVM Daemon Executable \"%s\"\n", tmp );
 
1029
                        printf( "Was Not Found on %s!\n", hp.hd_name );
 
1030
                        printf( "Has PVM been compiled there?\n" );
 
1031
 
 
1032
                        return( 0 );
 
1033
                }
 
1034
                else
 
1035
                        printf( "PVM Daemon Executable Found (\"%s\")\n", tmp );
 
1036
        }
 
1037
        else
 
1038
                return( 0 );
 
1039
 
 
1040
        /* Determine Remote Host Temp Directory (if set) */
 
1041
 
 
1042
        if ( do_rsh_cmd( &hp, "Determining PVM Temporary Directory on",
 
1043
                        ( remote_os == 0 ) ? "echo $PVM_TMP" : "echo %PVM_TMP%",
 
1044
                        result, 1024 ) ) {
 
1045
 
 
1046
                /* check for undefined variable */
 
1047
                if ( ( remote_os == 0 && check_env_var( "PVM_TMP", result ) )
 
1048
                                || ( remote_os == 1
 
1049
                                        && strncmp( result, "ECHO", 4 ) ) ) {
 
1050
                        printf( "%sPVM_TMP%s on %s set to %s\n",
 
1051
                                ( remote_os == 0 ) ? "$" : "%",
 
1052
                                ( remote_os == 0 ) ? "" : "%",
 
1053
                                hp.hd_name, result );
 
1054
                        strcpy( pvmtmp, result );
 
1055
                }
 
1056
                else {
 
1057
                        printf( "%sPVM_TMP%s not set on %s\n",
 
1058
                                ( remote_os == 0 ) ? "$" : "%",
 
1059
                                ( remote_os == 0 ) ? "" : "%",
 
1060
                                hp.hd_name );
 
1061
                        if ( remote_os == 1 ) {
 
1062
                                printf( "Assuming C:\\TEMP.\n" );
 
1063
                                strcpy( pvmtmp, "C:\\TEMP" );
 
1064
                        }
 
1065
                        else {
 
1066
                                printf( "Assuming /tmp.\n" );
 
1067
                                strcpy( pvmtmp, "/tmp" );
 
1068
                        }
 
1069
                }
 
1070
        }
 
1071
        else
 
1072
                return( 0 );
 
1073
 
 
1074
        /* Pvmd Already Running There / Leftover Pvmd Files? */
 
1075
 
 
1076
        if ( remote_os == 0 )
 
1077
                sprintf( tmp, "\\ls -l %s/pvmd.* | grep %s",
 
1078
                        pvmtmp, ( hp.hd_login != NULL ) ? hp.hd_login : user );
 
1079
        else
 
1080
                /* should really also check %TEMP% */
 
1081
                sprintf( tmp, "dir /B /L %s\\pvmd.%s",
 
1082
                        pvmtmp, ( hp.hd_login != NULL ) ? hp.hd_login : user );
 
1083
 
 
1084
        if ( do_rsh_cmd( &hp, "Checking for Leftover PVM Daemon Files on",
 
1085
                        tmp, result, 1024 ) ) {
 
1086
 
 
1087
                len = strlen( result );
 
1088
                /* Find Any? (Unix) */
 
1089
                if ( remote_os == 0 ) {
 
1090
                        /* search for a '/pvmd', if found assume a hit */
 
1091
                        for ( i=0 ; i < len - 1 ; i++ ) {
 
1092
                                /* bail out if "/bin/ls: ... No such file..." */
 
1093
                                if ( !strncmp( result + i, "ls:", 3 ) )
 
1094
                                        break;
 
1095
                                else if ( !strncmp( result + i, "/pvmd.", 6 ) ) {
 
1096
                                        printf( "\nPVM Daemon Files Found on %s!\n",
 
1097
                                                hp.hd_name );
 
1098
                                        printf(
 
1099
                                                "PVM Could Already Be Running or else it\n" );
 
1100
                                        printf( "crashed and left behind a %s/pvmd.<uid>\n",
 
1101
                                                pvmtmp );
 
1102
                                        printf( "daemon file.\n" );
 
1103
                                        printf(
 
1104
                                                "Halt PVM if it is running on %s, or else\n",
 
1105
                                                hp.hd_name );
 
1106
                                        printf( "remove any leftover %s/pvmd.* files.\n",
 
1107
                                                pvmtmp );
 
1108
 
 
1109
                                        return( 0 );
 
1110
                                }
 
1111
                        }
 
1112
                        printf( "No PVM Daemon Files Found.\n" );
 
1113
                }
 
1114
                /* Find Any? (Windows) */
 
1115
                else if ( remote_os == 1 && !strncmp( result, "pvmd", 4 ) ) {
 
1116
                        printf( "\nPVM Daemon Files Found on %s!\n", hp.hd_name );
 
1117
                        printf( "Either PVM is Already Running or else it\n" );
 
1118
                        printf( "crashed and left behind a \\TEMP\\pvmd.%s\n",
 
1119
                                ( hp.hd_login != NULL ) ? hp.hd_login : user );
 
1120
                        printf( "daemon file.\n" );
 
1121
                        printf( "Halt PVM if it is running on %s, or else\n",
 
1122
                                hp.hd_name );
 
1123
                        printf( "remove any leftover \\TEMP\\pvmd.* files.\n" );
 
1124
 
 
1125
                        return( 0 );
 
1126
                }
 
1127
                /* No Pvmd Files, O.K.? */
 
1128
                else
 
1129
                        printf( "No PVM Daemon Files Found.\n" );
 
1130
        }
 
1131
        else
 
1132
                return( 0 );
 
1133
 
 
1134
        /* Hmmm...  Must Be O.K. (ha ha ha) */
 
1135
 
 
1136
        printf( "\nHost %s Appears to Be Correctly Configured.\n",
 
1137
                hp.hd_name );
 
1138
#ifndef WIN32
 
1139
        printf( "Please check your local %s/pvml.%d log file\n",
 
1140
                pvmgettmp(), getuid() );
 
1141
#else
 
1142
        printf( "Please check your local %s\\pvml.%s log file\n",
 
1143
                pvmgettmp(), user );
 
1144
#endif
 
1145
        printf( "for error messages, or else email \"%s\" for\n",
 
1146
                "pvm@msr.csm.ornl.gov" );
 
1147
        printf( "further assistance.\n" );
 
1148
 
 
1149
        return( 1 );
 
1150
}
 
1151
 
 
1152
 
 
1153
do_rsh_cmd( hp, label, cmd, result, rsize )
 
1154
struct hostd *hp;
 
1155
char *label;
 
1156
char *cmd;
 
1157
char *result;
 
1158
int rsize;
 
1159
{
 
1160
        FILE *fp;
 
1161
 
 
1162
        char tfile[1024];
 
1163
        char tcmd[1024];
 
1164
        char tmp[255];
 
1165
 
 
1166
        int ret = 1;
 
1167
        int len;
 
1168
 
 
1169
        /* Generate Temporary File for Test Output */
 
1170
 
 
1171
        (void)PVMTMPNAMFUN(tfile);
 
1172
 
 
1173
        /* Dump Test Label */
 
1174
 
 
1175
        printf( "%s Host \"%s\"...\n", label, hp->hd_name );
 
1176
 
 
1177
        /* Construct Rsh Command */
 
1178
 
 
1179
        sprintf( tcmd, "%s ", pvmgetrsh() );
 
1180
 
 
1181
        if ( hp->hd_login != NULL ) {
 
1182
                sprintf( tmp, "-l %s ", hp->hd_login );
 
1183
                strcat( tcmd, tmp );
 
1184
        }
 
1185
 
 
1186
        sprintf( tmp, "%s '%s' ", hp->hd_name, cmd );
 
1187
        strcat( tcmd, tmp );
 
1188
 
 
1189
#ifndef WIN32
 
1190
        sprintf( tmp, "1>%s 2>&1", tfile );
 
1191
#else
 
1192
        sprintf( tmp, "> %s", tfile );
 
1193
#endif
 
1194
        strcat( tcmd, tmp );
 
1195
 
 
1196
        /* Execute Rsh Command */
 
1197
 
 
1198
        system( tcmd );
 
1199
 
 
1200
        /* Collect Rsh Command Results */
 
1201
 
 
1202
        fp = fopen( tfile, "r" );
 
1203
 
 
1204
        if ( fp != NULL ) {
 
1205
                if ( fgets( result, rsize, fp ) != NULL ) {
 
1206
                        /* strip off '\n' */
 
1207
                        len = strlen( result );
 
1208
                        if ( len > 0 && result[ len - 1 ] == '\n' )
 
1209
                                result[ len - 1 ] = '\0';
 
1210
                        /* strip off any '\r' */
 
1211
                        len = strlen( result );
 
1212
                        if ( len > 0 && result[ len - 1 ] == '\r' )
 
1213
                                result[ len - 1 ] = '\0';
 
1214
                }
 
1215
                else {
 
1216
                        printf( "Error Parsing Output - Can't Auto-Diagnose.\n" );
 
1217
                        ret = 0;
 
1218
                }
 
1219
                fclose( fp );
 
1220
        }
 
1221
        else {
 
1222
                printf( "Rsh Command Failed - Check Your Execution Path!\n" );
 
1223
                ret = 0;
 
1224
        }
 
1225
 
 
1226
        unlink( tfile );
 
1227
 
 
1228
        return( ret );
 
1229
}
 
1230
 
 
1231
 
 
1232
check_env_var( name, result )
 
1233
char *name;
 
1234
char *result;
 
1235
{
 
1236
        char *ptr;
 
1237
 
 
1238
        int nlen = strlen( name );
 
1239
 
 
1240
        /* Standard "FOO - Undefined variable" Response? */
 
1241
 
 
1242
        if ( !strncmp( result, name, nlen ) )
 
1243
                return( 0 );
 
1244
 
 
1245
        /* Check for preceding garbage before standard response */
 
1246
 
 
1247
        ptr = result + 1;
 
1248
 
 
1249
        while ( *ptr != '\0' && strlen( ptr ) >= nlen )
 
1250
        {
 
1251
                if ( !strncmp( ptr, name, nlen ) )
 
1252
                        return( 0 );
 
1253
                
 
1254
                ptr++;
 
1255
        }
 
1256
 
 
1257
        /* Look for "[Uu]ndefined" in result... */
 
1258
 
 
1259
        ptr = result;
 
1260
 
 
1261
        while ( *ptr != '\0' && strlen( ptr ) >= 9 )
 
1262
        {
 
1263
                if ( !strncmp( ptr, "Undefined", nlen )
 
1264
                                || !strncmp( ptr, "undefined", nlen ) )
 
1265
                        return( 0 );
 
1266
                
 
1267
                ptr++;
 
1268
        }
 
1269
 
 
1270
        /* Must Be O.K. */
 
1271
 
 
1272
        return( 1 );
 
1273
}
 
1274
 
 
1275
 
 
1276
/*      parsehost()
 
1277
*
 
1278
*       Parse hostfile line into hostd.
 
1279
*       (lifted from pvm3/src/host.c - pvmd code... hacked a little :-)
 
1280
*/
 
1281
 
 
1282
int
 
1283
parsehost(buf, hp)
 
1284
        char *buf;
 
1285
        struct hostd *hp;
 
1286
{
 
1287
        char *av[10];           /* parsed words */
 
1288
        int ac;
 
1289
        int err = 0;
 
1290
 
 
1291
        ac = sizeof(av)/sizeof(av[0]);
 
1292
        if (acav(buf, &ac, av)) {
 
1293
                printf("parsehost(): line too long\n");
 
1294
                goto bad;
 
1295
        }
 
1296
        if (!ac)
 
1297
                goto bad;
 
1298
 
 
1299
        /* Initialize Host Struct Fields */
 
1300
 
 
1301
        hp->hd_name = (char *) NULL;
 
1302
        hp->hd_arch = (char *) NULL;
 
1303
        hp->hd_login = (char *) NULL;
 
1304
        hp->hd_dpath = (char *) NULL;
 
1305
        hp->hd_epath = (char *) NULL;
 
1306
        hp->hd_bpath = (char *) NULL;
 
1307
        hp->hd_wdir = (char *) NULL;
 
1308
        hp->hd_sopts = (char *) NULL;
 
1309
        hp->hd_vmid = (char *) NULL;
 
1310
 
 
1311
        /* add options to host descriptor */
 
1312
 
 
1313
        while (--ac > 0) {
 
1314
                if (!strncmp(av[ac], "lo=", 3)) {
 
1315
                        if (hp->hd_login)
 
1316
                                MY_FREE(hp->hd_login);
 
1317
                        hp->hd_login = STRALLOC(av[ac] + 3);
 
1318
                        continue;
 
1319
                }
 
1320
                if (!strncmp(av[ac], "dx=", 3)) {
 
1321
                        if (hp->hd_dpath)
 
1322
                                MY_FREE(hp->hd_dpath);
 
1323
                        hp->hd_dpath = STRALLOC(av[ac] + 3);
 
1324
                        continue;
 
1325
                }
 
1326
                if (!strncmp(av[ac], "ep=", 3)) {
 
1327
                        if (hp->hd_epath)
 
1328
                                MY_FREE(hp->hd_epath);
 
1329
                        hp->hd_epath = STRALLOC(av[ac] + 3);
 
1330
                        continue;
 
1331
                }
 
1332
                if (!strncmp(av[ac], "sp=", 3)) {
 
1333
                        hp->hd_speed = atoi(av[ac] + 3);
 
1334
                        /* hp->hd_flag |= HF_SPEED; */
 
1335
                        continue;
 
1336
                }
 
1337
                if (!strncmp(av[ac], "bx=", 3)) {
 
1338
                        if (hp->hd_bpath)
 
1339
                                MY_FREE(hp->hd_bpath);
 
1340
                        hp->hd_bpath = STRALLOC(av[ac] + 3);
 
1341
                        continue;
 
1342
                }
 
1343
                if (!strncmp(av[ac], "wd=", 3)) {
 
1344
                        if (hp->hd_wdir)
 
1345
                                MY_FREE(hp->hd_wdir);
 
1346
                        hp->hd_wdir = STRALLOC(av[ac] + 3);
 
1347
                        continue;
 
1348
                }
 
1349
                if (!strncmp(av[ac], "so=", 3)) {
 
1350
                        if (hp->hd_sopts)
 
1351
                                MY_FREE(hp->hd_sopts);
 
1352
                        hp->hd_sopts = STRALLOC(av[ac] + 3);
 
1353
                        continue;
 
1354
                }
 
1355
                if (!strncmp(av[ac], "ip=", 3)) {
 
1356
                        if (hp->hd_aname)
 
1357
                                MY_FREE(hp->hd_aname);
 
1358
                        hp->hd_aname = STRALLOC(av[ac] + 3);
 
1359
                        continue;
 
1360
                }
 
1361
                if (!strncmp(av[ac], "id=", 3)) {
 
1362
                        if (hp->hd_vmid)
 
1363
                                MY_FREE(hp->hd_vmid);
 
1364
                        hp->hd_vmid = STRALLOC(av[ac] + 3);
 
1365
                        continue;
 
1366
                }
 
1367
                printf("parsehost(): unknown option \"%s\"\n", av[ac]);
 
1368
                err++;
 
1369
        }
 
1370
        if (err)
 
1371
                goto bad;
 
1372
 
 
1373
        if (hp->hd_name)
 
1374
                MY_FREE(hp->hd_name);
 
1375
        hp->hd_name = STRALLOC(av[0]);
 
1376
        return 0;
 
1377
 
 
1378
bad:
 
1379
        return -1;
 
1380
}
 
1381
 
 
1382
 
500
1383
alias_cmd(ac, av)
501
1384
        int ac;
502
1385
        char **av;
631
1514
        "export export      Add environment variables to spawn export list",
632
1515
        "export Syntax:  export [ varname ... ]",
633
1516
 
 
1517
        "getopt getopt      Display PVM options for the console task",
 
1518
        "getopt Syntax:  getopt [ what ]",
 
1519
 
634
1520
        "halt halt        Stop pvmds",
635
1521
        "halt Syntax:  halt",
636
1522
 
713
1599
        "setenv setenv      Display or set environment variables",
714
1600
        "setenv Syntax:  setenv [ name [ value ] ]",
715
1601
 
 
1602
        "setopt setopt      Set PVM options - for the console task *only*!",
 
1603
        "setopt Syntax:  setopt what value",
 
1604
 
716
1605
        "sig sig         Send signal to task",
717
1606
        "sig Syntax:  sig signum task ...",
718
1607
 
719
1608
        "spawn spawn       Spawn task",
720
1609
        "spawn Syntax:  spawn [ options ] file [ arg ... ]",
721
 
        "spawn Options:  -(count)  number of tasks, default is 1",
722
 
        "spawn           -(host)   spawn on host, default is any",
723
 
        "spawn           -(ARCH)   spawn on hosts of ARCH",
724
 
        "spawn           -?        enable debugging",
725
 
        "spawn           ->        redirect output of job to console",
726
 
        "spawn           ->(file)  redirect output of job to file",
727
 
        "spawn           ->>(file) append output of job to file",
728
 
        "spawn           -@        trace job, display output on console",
729
 
        "spawn           -@(file)  trace job, output to file",
 
1610
        "spawn Options:  -(count)         number of tasks, default is 1",
 
1611
        "spawn           -(host)          spawn on host, default is any",
 
1612
        "spawn           -(host):(wd)     spawn on host, in directory 'wd'",
 
1613
        "spawn           --host=(IP)      spawn on host with given IP addr",
 
1614
        "spawn           --host=(IP):(wd) spawn on IP, in directory 'wd'",
 
1615
        "spawn           -(ARCH)          spawn on hosts of ARCH",
 
1616
        "spawn           -(ARCH):(wd)     spawn on hosts of ARCH, in 'wd'",
 
1617
        "spawn           -:(wd)           spawn in working directory 'wd'",
 
1618
        "spawn           -?               enable debugging",
 
1619
        "spawn           ->               redirect job output to console",
 
1620
        "spawn           ->(file)         redirect output of job to file",
 
1621
        "spawn           ->>(file)        append output of job to file",
 
1622
        "spawn           -@               trace job, output to terminal",
 
1623
        "spawn           -@(file)         trace job, output to file",
730
1624
 
731
1625
        "tickle-tickle      Tickle pvmd",
732
1626
        "tickle-Syntax:  tickle how [ arg ... ]",
753
1647
        "tickle-        2048  Shared memory operations",
754
1648
        "tickle-        4096  Semaphores",
755
1649
        "tickle-        8192  Locks",
 
1650
        "tickle-       16384  Message routing",
 
1651
        "tickle-       32768  Message mailbox",
 
1652
        "tickle-       65536  Tracer tracing",
 
1653
        "tickle-      131072  Multicast tracking",
756
1654
        "tickle-  7   (num) set nopax",
757
1655
        "tickle-  8   (dtid) trigger hostfail",
758
1656
        "tickle-  9   (rst) dump pvmd statistics, clear if rst true",
873
1771
        int l = 0;
874
1772
        int ntask;
875
1773
        struct pvmtaskinfo *tip;
 
1774
        TRC_TEVTASK tt;
876
1775
 
877
1776
        if (ac > 1 && !strcmp(av[1], "-l")) {
878
1777
                l = 1;
884
1783
        for (jp = joblist->j_link; jp != joblist; jp = jp->j_link) {
885
1784
                printf("%c%d:%s", (jp->j_flag & JOB_TRACE ? 'T' : ' '),
886
1785
                                jp->j_jid - joboffset, (l ? "\n" : ""));
887
 
                if (jp->j_obufs) {
888
 
                        for (op = jp->j_obufs->o_link; op != jp->j_obufs; op = op->o_link)
 
1786
                if (jp->j_flag & JOB_TRACE) {
 
1787
                        tt = jp->j_trcid->tevtask_list;
 
1788
                        while ( tt ) {
 
1789
                                if ( tt->tevstatus == TRC_TASK_ALIVE
 
1790
                                                || tt->outstatus == TRC_TASK_OUT ) {
 
1791
                                        if (l) {
 
1792
                                                if (!pvm_tasks(tt->tid, &ntask, &tip)
 
1793
                                                                && ntask == 1)
 
1794
                                                        print_task_rec(&tip[0], 0);
 
1795
                                                else
 
1796
                                                        printf(" t%x", tt->tid);
 
1797
                                                printf("\n");
 
1798
                                        } else
 
1799
                                                printf(" t%x", tt->tid);
 
1800
                                }
 
1801
                                tt = tt->next;
 
1802
                        }
 
1803
                        if (!l)
 
1804
                                printf("\n");
 
1805
                }
 
1806
                else if (jp->j_obufs) {
 
1807
                        for (op = jp->j_obufs->o_link; op != jp->j_obufs;
 
1808
                                        op = op->o_link)
889
1809
                                if (l) {
890
 
                                        if (!pvm_tasks(op->o_tid, &ntask, &tip) && ntask == 1)
 
1810
                                        if (!pvm_tasks(op->o_tid, &ntask, &tip)
 
1811
                                                        && ntask == 1)
891
1812
                                                print_task_rec(&tip[0], 0);
892
1813
                                        else
893
1814
                                                printf(" t%x", op->o_tid);
1122
2043
}
1123
2044
 
1124
2045
 
 
2046
static char *setop_strs[] = {
 
2047
        "PvmRoute",
 
2048
        "PvmDebugMask",
 
2049
        "PvmAutoErr",
 
2050
        "PvmOutputTid",
 
2051
        "PvmOutputCode",
 
2052
        "PvmTraceTid",
 
2053
        "PvmTraceCode",
 
2054
        "PvmTraceBuffer",
 
2055
        "PvmTraceOptions",
 
2056
        "PvmFragSize",
 
2057
        "PvmResvTids",
 
2058
        "PvmSelfOutputTid",
 
2059
        "PvmSelfOutputCode",
 
2060
        "PvmSelfTraceTid",
 
2061
        "PvmSelfTraceCode",
 
2062
        "PvmSelfTraceBuffer",
 
2063
        "PvmSelfTraceOptions",
 
2064
        "PvmShowTids",
 
2065
#if defined(IMA_AIX4MP) || defined(IMA_AIX5MP) \
 
2066
                || defined(IMA_ALPHAMP) || defined(IMA_CSPP) \
 
2067
                || defined(IMA_HPPAMP) || defined(IMA_RS6KMP) \
 
2068
                || defined(IMA_SGIMP) || defined(IMA_SGIMP6) \
 
2069
                || defined(IMA_SGIMP64) || defined(IMA_SUNMP)
 
2070
        "PvmPollType",
 
2071
        "PvmPollTime",
 
2072
#else
 
2073
        "",
 
2074
        "",
 
2075
#endif
 
2076
        "PvmOutputContext",
 
2077
        "PvmTraceContext",
 
2078
        "PvmSelfOutputContext",
 
2079
        "PvmSelfTraceContext",
 
2080
        "PvmNoReset",
 
2081
        NULL
 
2082
};
 
2083
 
 
2084
 
 
2085
setopt_cmd(ac, av)
 
2086
        int ac;
 
2087
        char **av;
 
2088
{
 
2089
        char **name;
 
2090
        int what = -1;
 
2091
        int value;
 
2092
        int cc;
 
2093
        int i;
 
2094
 
 
2095
        name = setop_strs;
 
2096
 
 
2097
        i = 1;
 
2098
 
 
2099
        while ( *name != NULL && what < 0 ) {
 
2100
                if ( !strcmp( *name, av[1] ) )
 
2101
                        what = i;
 
2102
                else {
 
2103
                        name++; i++;
 
2104
                }
 
2105
        }
 
2106
 
 
2107
        if ( what > 0 ) {
 
2108
                value = atoi( av[2] );
 
2109
                cc = pvm_setopt( what, value );
 
2110
                printf("%s Changed from %d to %d\n", av[1], cc, value );
 
2111
        }
 
2112
        else
 
2113
                printf("PVM Option \"%s\" Unknown.\n", av[1] );
 
2114
 
 
2115
        return 0;
 
2116
}
 
2117
 
 
2118
 
 
2119
getopt_cmd(ac, av)
 
2120
        int ac;
 
2121
        char **av;
 
2122
{
 
2123
        char **name;
 
2124
        int what = -1;
 
2125
        int value;
 
2126
        int cc;
 
2127
        int i;
 
2128
 
 
2129
        switch( ac ) {
 
2130
 
 
2131
        case 1:
 
2132
                name = setop_strs;
 
2133
                i = 1;
 
2134
                while ( *name != NULL ) {
 
2135
                        if ( strcmp( *name, "" ) ) {
 
2136
                                cc = pvm_getopt( i );
 
2137
                                printf("%s Currently Set to %d\n", *name, cc );
 
2138
                        }
 
2139
                        name++; i++;
 
2140
                }
 
2141
                break;
 
2142
 
 
2143
        case 2:
 
2144
                name = setop_strs;
 
2145
                i = 1;
 
2146
                while ( *name != NULL && what < 0 ) {
 
2147
                        if ( !strcmp( *name, av[1] ) )
 
2148
                                what = i;
 
2149
                        else {
 
2150
                                name++; i++;
 
2151
                        }
 
2152
                }
 
2153
                if ( what > 0 ) {
 
2154
                        cc = pvm_getopt( what );
 
2155
                        printf("%s Currently Set to %d\n", av[1], cc );
 
2156
                }
 
2157
                else
 
2158
                        printf("PVM Option \"%s\" Unknown.\n", av[1] );
 
2159
                break;
 
2160
        }
 
2161
 
 
2162
        return 0;
 
2163
}
 
2164
 
 
2165
 
1125
2166
sig_cmd(ac, av)
1126
2167
        int ac;
1127
2168
        char **av;
1171
2212
                        where = av[1] + 1;
1172
2213
                        flags |= PvmTaskHost;
1173
2214
                }
 
2215
                if (av[1][1] == ':')
 
2216
                        where = av[1] + 1;
1174
2217
                if (isupper(av[1][1])) {
1175
2218
                        where = av[1] + 1;
1176
2219
                        flags |= PvmTaskArch;
1200
2243
                        if (!*tfn)
1201
2244
                                tfn = "";
1202
2245
                }
 
2246
                /* gnu-like host (where) arg, allows IP's to be used... */
 
2247
                if (av[1][1] == '-') {
 
2248
                        if ( !strncmp( &(av[1][2]), "host=", 5 ) ) {
 
2249
                                where = av[1] + 7;
 
2250
                                flags |= PvmTaskHost;
 
2251
                        }
 
2252
                }
1203
2253
                av++;
1204
2254
                ac--;
1205
2255
        }