Noux: add F_GETFL handling to terminal_io_channel

There are certain programms which check if an fd is open by calling
fcntl(fd, F_GETFL, ...). So to keep them happy we return true if
such an request was done to our terminal fd's.
This commit is contained in:
Josef Söntgen 2012-06-11 12:05:32 +02:00 committed by Norman Feske
parent 7dfbd9e191
commit 343266b06e
1 changed files with 27 additions and 0 deletions

View File

@ -108,6 +108,33 @@ namespace Noux {
return true;
}
bool fcntl(Sysio *sysio)
{
/**
* Actually it is "inappropiate" to use fcntl() directly on terminals
* (atleast according to the Open Group Specification). We do it anyway
* since in our case stdout/in/err is directly connected to the terminal.
*
* Some GNU programms check if stdout is open by calling fcntl(stdout, F_GETFL, ...).
*/
switch (sysio->fcntl_in.cmd) {
case Sysio::FCNTL_CMD_GET_FILE_STATUS_FLAGS:
{
sysio->fcntl_out.result = 0;
return true;
}
default:
{
return false;
}
}
return false;
}
bool fstat(Sysio *sysio)
{
/*