/*
*
*
* A simple launcher to launch a program as if it was launched by inetd.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <ctype.h>
#include "jni.h"
#include "Launcher.h"
/*
* Throws the exception of the given class name and detail message
*/
}
}
/*
* Convert a jstring to an ISO 8859_1 encoded C string
*/
int i;
char *result;
if (str == 0) {
return NULL;
}
if (result == 0) {
return NULL;
}
for (i=0; i<len; i++) {
if (unicode <= 0x00ff)
else
result[i] = '?';
}
return result;
}
/*
* Class: Launcher
* Method: launch0
*/
{
int thisFd;
char** cmdv;
int i, cmdlen;
/*
* Argument 0 of the command array is the program name.
* Here we just extract the program name and any arguments into
* a command array suitable for use with execvp.
*/
if (cmdlen == 0) {
"command array must at least include the program name");
return;
}
return;
}
for (i=0; i<cmdlen; i++) {
return;
}
}
/*
* Command array must have NULL as the last entry
*/
/*
* Launch the program. As this isn't a complete inetd or Runtime.exec
* implementation we don't have a reaper to pick up child exit status.
*/
#ifdef __solaris__
#else
#endif
if (pid != 0) {
if (pid < 0) {
}
return;
}
/*
* We need to close all file descriptors except for serviceFd. To
* but to open this requires a file descriptor. We could use a specific
* file descriptor and fdopendir but Linux doesn't seem to support
* fdopendir. Instead we use opendir and make an assumption on the
* file descriptor that is used (by opening & closing a file).
*/
if (thisFd < 0) {
_exit(-1);
}
_exit(-1);
}
}
}
}
/*
* At this point all file descriptors are closed except for
* serviceFd. We not dup 0,1,2 to this file descriptor and
* close serviceFd. This should leave us with only 0,1,2
* open and all connected to the same socket.
*/
_exit(-1);
}