mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Don't use fstat for readable pipe chars in dtexec.
The dtexec code assumes that fstat reports pipe's readable chars. Linux always reports 0 for st_size of a pipe. Instead read one character when select reports readable. Note EOF when select says readable but read returns 0.
This commit is contained in:
parent
bd70163b09
commit
f0a60e47b1
1 changed files with 13 additions and 11 deletions
|
@ -1163,7 +1163,6 @@ main (
|
||||||
int junki,i;
|
int junki,i;
|
||||||
char *tmpBuffer;
|
char *tmpBuffer;
|
||||||
int errorBytes;
|
int errorBytes;
|
||||||
struct stat statBuffer;
|
|
||||||
int firstPass, tmpi;
|
int firstPass, tmpi;
|
||||||
char *tmpProgName = NULL;
|
char *tmpProgName = NULL;
|
||||||
|
|
||||||
|
@ -1390,27 +1389,30 @@ main (
|
||||||
firstPass = 1;
|
firstPass = 1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if ( fstat(errorpipeG[0], &statBuffer) ) {
|
char buf;
|
||||||
break;
|
nfound =select(MAXSOCKS, FD_SET_CAST(&readfds), FD_SET_CAST(NULL),
|
||||||
|
FD_SET_CAST(NULL), &timeoutShort);
|
||||||
|
if (nfound > 0) {
|
||||||
|
tmpi = read (errorpipeG[0], &buf, 1);
|
||||||
|
} else {
|
||||||
|
tmpi = 0;
|
||||||
}
|
}
|
||||||
else if ( statBuffer.st_size > 0 ) {
|
|
||||||
|
if ( tmpi > 0 ) {
|
||||||
/*
|
/*
|
||||||
* Grow buffer to hold entire error stream.
|
* Grow buffer to hold entire error stream.
|
||||||
*/
|
*/
|
||||||
firstPass = 0;
|
firstPass = 0;
|
||||||
if (tmpBuffer == NULL)
|
if (tmpBuffer == NULL)
|
||||||
tmpBuffer = (char *) malloc(
|
tmpBuffer = (char *) malloc(
|
||||||
statBuffer.st_size + 1);
|
tmpi + 1);
|
||||||
else
|
else
|
||||||
tmpBuffer = (char *) realloc( tmpBuffer,
|
tmpBuffer = (char *) realloc( tmpBuffer,
|
||||||
errorBytes +
|
errorBytes + tmpi + 1);
|
||||||
statBuffer.st_size + 1);
|
|
||||||
/*
|
/*
|
||||||
* Drain error pipe.
|
* Drain error pipe.
|
||||||
*/
|
*/
|
||||||
tmpi = read (errorpipeG[0], &tmpBuffer[errorBytes],
|
tmpBuffer[errorBytes] = buf;
|
||||||
statBuffer.st_size);
|
|
||||||
if (tmpi > 0) /* else let fstat() redetect problem */
|
|
||||||
errorBytes += tmpi;
|
errorBytes += tmpi;
|
||||||
tmpBuffer[errorBytes] = '\0';
|
tmpBuffer[errorBytes] = '\0';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue