From: John Hodge Date: Sat, 19 Feb 2011 09:06:07 +0000 (+0800) Subject: Let's try this again... X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d0ec658923323d126ffbe20e0c7a439affc5a6ea;p=tpg%2Fopendispense2.git Let's try this again... --- diff --git a/src/server/handler_door.c b/src/server/handler_door.c index 968c3b8..1f959fd 100644 --- a/src/server/handler_door.c +++ b/src/server/handler_door.c @@ -77,11 +77,9 @@ int Door_DoDispense(int User, int Item) { FILE *child_stdin; char buf[512]; - #if !USE_POPEN int stdin_pair[2]; int stdout_pair[2]; pid_t childPid; - #endif #if DEBUG printf("Door_DoDispense: (User=%i,Item=%i)\n", User, Item); @@ -99,7 +97,6 @@ int Door_DoDispense(int User, int Item) return 1; } - #if !USE_POPEN // Create stdin/stdout if( pipe(stdin_pair) || pipe(stdout_pair) ) { @@ -132,18 +129,7 @@ int Door_DoDispense(int User, int Item) close(stdin_pair[0]); // child stdin read close(stdout_pair[1]); // child stdout write - #else - // llogin or other - child_stdin = popen("llogin door -w -", "w"); - if( !child_stdin || child_stdin == (void*)-1 ) { - #if DEBUG - printf("Door_DoDispense: llogin failure\n"); - #endif - return -1; - } - #endif - - if(fread(buf, 1, 512, child_stdin) == 0) { + if(read(stdout_pair[1], buf, 512) < 0) { #if DEBUG printf("Door_DoDispense: fread fail\n"); #endif @@ -188,13 +174,9 @@ int Door_DoDispense(int User, int Item) return -1; } - #if !USE_POPEN fclose(child_stdin); close(stdin_pair[1]); // child stdin write close(stdout_pair[0]); // child stdout read - #else - pclose(child_stdin); - #endif #if DEBUG printf("Door_DoDispense: User %i opened door\n", User);