struct termios raw_attrs;
int r;
+ // Skip everything if fd is not a TTY
+ if (!isatty(stdio->fd))
+ return 0;
+
// Store flags
stdio->fdflags = fcntl(stdio->fd, F_GETFL);
if (stdio->fdflags < 0) {
const struct pakfire_jail_pty_stdio* stdio) {
int r;
+ // Skip everything if fd is not a TTY
+ if (!isatty(stdio->fd))
+ return 0;
+
// Restore the flags
r = fcntl(stdio->fd, F_SETFL, stdio->fdflags);
if (r < 0) {
ctx->pty.stdout.fd = STDOUT_FILENO;
// Fetch dimensions
- r = ioctl(ctx->pty.stdout.fd, TIOCGWINSZ, &size);
- if (r) {
- CTX_ERROR(jail->ctx, "Failed to determine terminal dimensions: %s\n", strerror(errno));
- return -errno;
- }
+ if (isatty(ctx->pty.stdout.fd)) {
+ r = ioctl(ctx->pty.stdout.fd, TIOCGWINSZ, &size);
+ if (r) {
+ CTX_ERROR(jail->ctx, "Failed to determine terminal dimensions: %s\n", strerror(errno));
+ return -errno;
+ }
- // Set dimensions
- r = ioctl(ctx->pty.master.fd, TIOCSWINSZ, &size);
- if (r) {
- CTX_ERROR(jail->ctx, "Failed setting dimensions: %s\n", strerror(errno));
- return -errno;
+ // Set dimensions
+ r = ioctl(ctx->pty.master.fd, TIOCSWINSZ, &size);
+ if (r) {
+ CTX_ERROR(jail->ctx, "Failed setting dimensions: %s\n", strerror(errno));
+ return -errno;
+ }
}
// Enable RAW mode on standard input