Skip to content

Commit

Permalink
don't create status fifo until we are about to send command.
Browse files Browse the repository at this point in the history
this allows us to print an error in the case where the jvm exits prematurely
  • Loading branch information
ninjudd committed Jan 26, 2013
1 parent 7db4f14 commit 6af2aa8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classes/%.class: src/%.java
${javac} ${java_src} -d classes/

bin/%: src/%.c
gcc $< -o $@
gcc -std=c99 $< -o $@

${jar}: ${classes}
jar cf ${jar} -C src/ org
Expand Down
2 changes: 1 addition & 1 deletion bin/drip
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function launch_jvm {

if mkdir "$jvm_dir"; then
mkfifo "$jvm_dir/control"
mkfifo "$jvm_dir/status"

DRIP_INIT_CLASS=${DRIP_INIT_CLASS:-$main_class}
export DRIP_INIT_CLASS=${DRIP_INIT_CLASS//\//.}
Expand Down Expand Up @@ -283,6 +282,7 @@ function send_env {
}

function send_args {
mkfifo "$active_jvm_dir/status"
exec 4> "$active_jvm_dir/control"
send_array "${main_args[@]}" >&4
send_array "${runtime_args[@]}" >&4
Expand Down
14 changes: 13 additions & 1 deletion src/drip_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>

static char* jvm_dir;

Expand Down Expand Up @@ -44,6 +46,16 @@ int main(int argc, char **argv) {

int status;
wait(&status);
spit_int("status", status/256);

status /= 256;
if (access("status", F_OK) != -1) {
spit_int("status", status);
} else {
fprintf(stderr, "java process exited prematurely with status %d: ", status);
for (int i=1; i < argc; i++) {
fprintf(stderr, "%s ", argv[i]);
}
fprintf(stderr, "\n");
}
}
}
2 changes: 2 additions & 0 deletions src/drip_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>

Expand Down

0 comments on commit 6af2aa8

Please sign in to comment.