Skip to content

Commit

Permalink
Merge d997f35 into d0c7f21
Browse files Browse the repository at this point in the history
  • Loading branch information
akgrant43 committed May 16, 2018
2 parents d0c7f21 + d997f35 commit 0518ccb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c
Expand Up @@ -582,8 +582,19 @@ sqFileStdioHandlesInto(SQFile files[])
* 4 - cygwin terminal (windows only)
*/
sqInt sqFileDescriptorType(int fdNum) {
/* TODO Implement the unix version */
return isatty(fdNum);
int status;
struct stat statBuf;

/* Is this a terminal? */
if (isatty(fdNum)) return 1;

/* Is this a pipe? */
status = fstat(fdNum, &statBuf);
if (status) return -1;
if (S_ISFIFO(statBuf.st_mode)) return 2;

/* Must be a normal file */
return 3;
}


Expand Down

0 comments on commit 0518ccb

Please sign in to comment.