39
* Revision 1.81 2004/09/08 19:35:36 pvmsrc
40
* Added #ifdef IMA_AIX56K64 to unsigned int oslen fiasco...
43
* Revision 1.80 2004/02/06 20:05:38 pvmsrc
44
* Yanked out all the AMD64 test crap.
45
* - it was just the time.h header all along...! ;-/~
48
* Revision 1.79 2004/02/06 16:50:36 pvmsrc
49
* Yet more ctime() test crap for AMD64...
52
* Revision 1.78 2004/02/04 23:30:14 pvmsrc
53
* Yet more temp AMD64 hacks...
56
* Revision 1.77 2004/02/04 21:46:23 pvmsrc
57
* Temp hack for AMD64 seg fault...
60
* Revision 1.76 2004/01/14 18:51:02 pvmsrc
61
* Added new AIX5* arches.
64
* Revision 1.75 2002/10/14 19:23:12 pvmsrc
65
* Oops! Need to htons() to convert the host byte to network byte order!
66
* - for PVMNETSOCKPORT cruft...
69
* Revision 1.74 2002/10/07 14:30:32 pvmsrc
70
* Added new PVMNETSOCKPORT env var for mksocs().
71
* - allow starting port address for netsock binding, in the hopes
72
* that PVM will get a port that is allowed access through a
77
* Revision 1.73 2002/07/03 16:57:54 pvmsrc
78
* Fixes for compilation on Linux Alpha.
79
* - submitted by "David Mathog" <mathog@mendel.bio.caltech.edu>.
82
* Revision 1.72 2002/04/16 15:06:02 pvmsrc
83
* WIN32 Fixes for Multiple Domains.
84
* - submitted by Jigen Zhou <jigen@icemcfd.com>.
87
* Revision 1.71 2002/02/21 23:17:40 pvmsrc
88
* Added new (not to be documented!) PVM_MAX_TASKS env var support.
89
* - for Mahir Lokvancic <mahir@math.ufl.edu>.
90
* - forcefully limits the number of tasks that can attach to a
91
* pvmd, required on Solaris in rare circumstances when hard
92
* FD_SETSIZE limit is reached, and all hell breaks loose...
93
* - set new pvm_max_ntasks global depending on env var (0 = no limit)
94
* - check return for task_new() call, can now produce NULL ptr,
95
* indicating PvmOutOfRes...
98
* Revision 1.70 2001/12/07 16:06:11 pvmsrc
99
* Oops! Some new Unix fixes & features break Windows (of course!).
100
* - #ifdef-ed away fcntl() calls for non-blocking sockets / stdin.
101
* (one for bug fix in lpvm.c, one for check_ext_input() in pvmd.c)
104
* Revision 1.69 2001/11/26 17:45:12 pvmsrc
105
* Added #define for MAXPATHLEN for goofy arches... :-)
108
* Revision 1.68 2001/09/28 12:43:18 pvmsrc
109
* D-Oh! Stupid Solaris doesn't recognize FNDELAY, only O_NDELAY... :-Q
112
* Revision 1.67 2001/09/27 21:25:11 pvmsrc
114
* - submitted by Joe Vitale <vitale@scyld.com>.
115
* (we renamed it from BEOWULF to BEOSCYLD, but it's his port... :-)
118
* Revision 1.66 2001/09/26 21:23:21 pvmsrc
119
* Added Handling for Optional Virtual Machine ID.
120
* - added new check_ext_input() routine to check for extension
121
* options on stdin before anything else happens... currently
122
* only expects env string a la "PVM_VMID=xxxx", but more options
123
* could be added on same input line, white-space-separated...
124
* - extra vmid comes through with SM_STHOST message (after wincmd)
126
* - user instructed to type VMID (or other options) to pvmd stdin
127
* during manual startup.
130
* Revision 1.65 2001/09/25 21:20:19 pvmsrc
131
* Minor TMPNAMFUN()/tmpnam() cleanup.
132
* - moved macro def to pvm3.h, renamed PVMTNPMAN().
133
* - same for LEN_OF_TMP_NAM -> PVMTMPNAMLEN.
134
* - mostly a huge waste of time, since *both* tmpnam() & mktemp()
135
* produce the same "dangerous" warning message in Linux/gcc...
139
* Revision 1.64 2001/04/04 15:13:58 pvmsrc
140
* Fixed pesky bug buried in pvmd opq...
141
* - ack packets were being stuck at the end of the output queue,
142
* where they could get delayed (not lost) long enough to trigger
143
* a cascade of packet retries from remote pvmds.
144
* - solution is to stick ack packets after new (zero-rtv) packets,
145
* but before and locally queued retry packets (which can block
146
* processing of the opq at a specified time...).
147
* Yanked Bogus chdir() from WIN32 forkexec().
148
* - patch submitted by Peter J. Puchyr, SpaceTime Software
151
* Revision 1.63 2001/02/07 23:15:51 pvmsrc
152
* 2nd Half of CYGWIN Check-ins...
155
* Revision 1.62 2001/02/02 14:50:26 pvmsrc
156
* Win32 fixes & additions.
159
* Revision 1.61 2000/10/11 20:50:24 pvmsrc
161
* - fixed '//' comments in WIN32 forkexec() implementation to
163
* - apparently intereferes with SUN4SOL2 preprocessor? HOW BOGUS.
166
* Revision 1.60 2000/02/18 15:48:43 pvmsrc
167
* Commented out ECONNREFUSED check for sendto() in LINUX.
168
* - apparently results from local networking problems...
169
* - leave in code as a sign post for future occurrences.
172
* Revision 1.59 2000/02/17 23:12:16 pvmsrc
173
* *** Changes for new BEOLIN port ***
174
* - MPP-like, similar to SP2, etc.
175
* - submitted by Paul Springer <pls@smokeymt.jpl.nasa.gov>.
176
* - format-checked & cleaned up by Jeembo... :-)
179
* Revision 1.58 2000/02/17 16:42:56 pvmsrc
180
* Added hack to ignore errno=ECONNREFUSED from sendto() for Linux.
181
* - apparently occurs intermittently on some setups...
182
* - patch submitted by Russell Mora <rd.mora@auckland.ac.nz>.
185
* Revision 1.57 2000/02/16 22:01:25 pvmsrc
186
* Fixed up #include <sys/types.h> stuff...
187
* - use <bsd/sys/types.h> for IMA_TITN...
188
* - #include before any NEEDMENDIAN #includes...
189
* Added #ifndef NO_NETINET_TCP_H around <netinet/tcp.h> for
190
* archs that can't handle it... :-)
193
* Revision 1.56 2000/02/11 21:04:03 pvmsrc
194
* Added new PVMHOSTFILE env var.
195
* - submitted by Anders Mundt Due <amd@pd-house.dk>.
198
* Revision 1.55 2000/02/10 20:46:12 pvmsrc
199
* Yanked char *pvmtmpspec for WIN32.
200
* - not necessary, fixed string manip in log file name gen.
203
* Revision 1.54 2000/02/07 22:22:10 pvmsrc
204
* Hack to help with select()/fd_sets in WIN32:
205
* - fd_set is *NOT* a bit field in WIN32, is a circular buffer.
206
* - must check for !FD_ISSET() before FD_SET() else duplicate
207
* entries possible, and fd_set buffer overflow/overwrite.
208
* - similary, FD_ISSET() check before FD_CLR().
209
* - patch submitted by "Bruce W. Church" <bwc1@cornell.edu>.
39
212
* Revision 1.53 1999/07/08 19:00:07 kohl
40
213
* Fixed "Log" keyword placement.
41
214
* - indent with " * " for new CVS.
3626
4003
execv(argv[0], argv);
4007
/* if we're running on the master */
4008
if(node == BPROC_NODE_MASTER) {
4009
/* simply call execv */
4012
/* if we're running on a slave node */
4014
/* migrate process back to the master */
4015
if(bproc_move(BPROC_NODE_MASTER) != -1) {
4016
/* locate the executable */
4017
for(ep = eplist; *ep; ep++) {
4019
if(path[0]) strcat(path,"/");
4020
strncat(path,name,sizeof(path)-strlen(path)-1);
4021
if((stat(path,&sb) == -1) ||
4022
((sb.st_mode & S_IFMT) != S_IFREG) ||
4023
!(sb.st_mode & S_IEXEC)) {
4024
/* try the next path */
4028
/* execmove back to the slave */
4029
bproc_execmove(node,path,argv,env);
4030
/* if we get this far, the call to execmove
4031
* failed and we now have a ghost job back
4032
* on the slave and this whacked job on the
4033
* master; if we exit, both jobs are cleaned
4034
* up through the magic of bproc
4039
/* if we fell through the loop, we didn't
4040
* find the executable file; in this case
4041
* we move back to the slave and return
4043
if(bproc_move(node) == -1) {
4044
/* if the move back to the slave fails,
4045
* we have a ghost job back on the slave
4046
* and this whacked job on the master;
4047
* if we exit, both jobs are cleaned up
4048
* through the magic of bproc
4053
/* since the move back to the slave was
4054
* successfully and we were unable to find
4055
* the executable back on the master, we
4056
* mimic forkexec's normal functionality
4057
* of ending the for-loop
4062
else if (pvmdebmask & PDMTASK) {
4064
"forkexec() bproc move to master failed\n");
4066
/* end-if moving to master */
4068
/* end-if running on a slave */
3629
4070
execv(path, argv);
3720
4162
pvmlogerror("forkexec() out of tids?\n");
3721
4163
return PvmOutOfRes;
3724
// PIPE SECURITY STUFF
4165
if ((tp = task_new(tid)) == NULL) {
4166
pvmlogerror("forkexec() too many tasks?\n");
4169
/* PIPE SECURITY STUFF */
3726
4171
InitializeSecurityDescriptor(&SecDescript,SECURITY_DESCRIPTOR_REVISION);
3727
4172
SetSecurityDescriptorDacl(&SecDescript,TRUE,NULL,FALSE);
3729
// Set the bInheritHandle flag so pipe handles are inherited.
4174
/* Set the bInheritHandle flag so pipe handles are inherited. */
3731
4176
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
3732
4177
saAttr.bInheritHandle = TRUE;
3733
4178
saAttr.lpSecurityDescriptor = &SecDescript;
3735
// The steps for redirecting child process's STDOUT:
3736
// 1. Save current STDOUT, to be restored later.
3737
// 2. Create anonymous pipe to be STDOUT for child process.
3738
// 3. Set STDOUT of the parent process to be write handle of
3739
// the pipe, so it is inherited by the child process.
3740
// 4. Create a noninheritable duplicate of the read handle and
3741
// close the inheritable read handle.
4181
The steps for redirecting child process's STDOUT:
4182
1. Save current STDOUT, to be restored later.
4183
2. Create anonymous pipe to be STDOUT for child process.
4184
3. Set STDOUT of the parent process to be write handle of
4185
the pipe, so it is inherited by the child process.
4186
4. Create a noninheritable duplicate of the read handle and
4187
close the inheritable read handle.
3743
// Save the handle to the current STDOUT.
4190
/* Save the handle to the current STDOUT. */
3745
4192
hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE);
3746
4193
if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
3747
4194
pvmlogprintf("Stdout pipe creation failed\n");
3749
// Set a write handle to the pipe to be STDOUT.
4196
/* Set a write handle to the pipe to be STDOUT. */
3751
4198
if (! SetStdHandle(STD_OUTPUT_HANDLE, hChildStdoutWr))
3752
4199
pvmlogprintf("Redirecting STDOUT failed");
3754
// Create noninheritable read handle and close the inheritable read
4201
/* Create noninheritable read handle and close the inheritable */
3757
4204
fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd,
3758
4205
GetCurrentProcess(), &hChildStdoutRdDup , 0,
3762
4209
pvmlogprintf("DuplicateHandle failed");
3763
4210
CloseHandle(hChildStdoutRd);
3765
// The steps for redirecting child process's STDIN:
3766
// 1. Save current STDIN, to be restored later.
3767
// 2. Create anonymous pipe to be STDIN for child process.
3768
// 3. Set STDIN of the parent to be the read handle of the
3769
// pipe, so it is inherited by the child process.
3770
// 4. Create a noninheritable duplicate of the write handle,
3771
// and close the inheritable write handle.
4213
The steps for redirecting child process's STDIN:
4214
1. Save current STDIN, to be restored later.
4215
2. Create anonymous pipe to be STDIN for child process.
4216
3. Set STDIN of the parent to be the read handle of the
4217
pipe, so it is inherited by the child process.
4218
4. Create a noninheritable duplicate of the write handle,
4219
and close the inheritable write handle.
3773
// Save the handle to the current STDIN.
4222
/* Save the handle to the current STDIN. */
3775
4224
hSaveStdin = GetStdHandle(STD_INPUT_HANDLE);
3777
// Create a pipe for the child process's STDIN.
4226
/* Create a pipe for the child process's STDIN. */
3779
4228
if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
3780
4229
pvmlogprintf("Stdin pipe creation failed\n");
3782
// Set a read handle to the pipe to be STDIN.
4231
/* Set a read handle to the pipe to be STDIN. */
3784
4233
if (! SetStdHandle(STD_INPUT_HANDLE, hChildStdinRd))
3785
4234
pvmlogprintf("Redirecting Stdin failed");
3787
// Duplicate the write handle to the pipe so it is not inherited.
4236
/* Duplicate the write handle to the pipe so it is not inherited. */
3789
4238
fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr,
3790
4239
GetCurrentProcess(), &hChildStdinWrDup, 0,
3791
FALSE, // not inherited
4240
FALSE, /* not inherited */
3792
4241
DUPLICATE_SAME_ACCESS);
3793
4242
if (! fSuccess)
3794
4243
pvmlogprintf("DuplicateHandle failed");