So what I did was to check /proc/self/fd/0, in case it's not /dev/pts/something I skip the select
command. Check your fd 0 using something like this
bool rc = true;
char linkName[256];
const char* fd0 = "/proc/self/fd/0";
const char* devPts = "/dev/pts";
struct stat sb;
lstat(fd0, &sb);
readlink(fd0, linkName, sb.st_size + 1);
linkName[sb.st_size] = '\0';
if (strncmp(linkName, devPts, sizeof(devPts)) != 0)
{
std::cout << "The application's stdin file descriptor doesn't point to /dev/pts/XXX, input will be ignored" << std::endl;
rc = false;
}
return rc;