X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=blobdiff_plain;f=usystem.c;h=743c701c8c12744bf9c02280329fab83f52fbaa2;hp=23b798b784bac70c393a0daed72daad259f67b28;hb=HEAD;hpb=de1e5c90f7dc200af953878230331fefe4b38ed7 diff --git a/usystem.c b/usystem.c index 23b798b..743c701 100644 --- a/usystem.c +++ b/usystem.c @@ -519,15 +519,25 @@ DestroyChildProcess (ProcRef pr, int signalType) char * BufferCommandOutput (char *command, int size) { - ChildProc *pr; char *res = (char *) calloc(1, size); if(res) { int count; + FILE *f; +#if 0 + ChildProc *pr; StartChildProcess(command, ".", (ProcRef) &pr); // run command in daughter process - count = read(pr->fdFrom, res, size-1); // read its output - res[count > 0 ? count : 0] = NULLCHAR; + f = fdopen(pr->fdFrom, "r"); + count = fread(res, 1, size-1, f); // read its output + fclose(f); DestroyChildProcess((ProcRef) pr, 9); free(pr); +#else + f = popen(command, "r"); + if(!f) return res; + count = fread(res, 1, size-1, f); // read its output + pclose(f); +#endif + res[count > 0 ? count : 0] = NULLCHAR; } return res; // return buffer with output }