I'm using strace with this code:

#!/usr/bin/env bash

exec 0<test.log
while IFS= read -r line; do
    printf "%s\n" "$line"

(The straight <test.log redirection gives the same result.)

I'm getting this error for each read line:

ioctl(0, TCGETS, 0x7fff1e645d50)        = -1 ENOTTY (Inappropriate ioctl for device)

I've done some research and this is the nearest answer. It's far from being spot-on though. My script works fine, I'm just wondering if this is something I should deal with or just the standard way of Bash. Isn't it striking that the ioctl function is called for each line? I had a thought that the -u parameter to Bash might be related:

-u fd  Read input from file descriptor fd.

I've done some experiments to no avail. So how this option is supposed to be used may be another question.

I'm on Ubuntu 16.04 with Bash 4.3.48(1)-release.

1 Answer 1


You can't get rid of it and there's no reason to remove it anyway. This comes from bash checking whether the input is coming from a terminal (it calls isatty). It doesn't actually use this information in your case, only when various options are passed. If you're curious about the details, read the source code (read_builtin function in builtins/read.def).

The fact that the TCGETS ioctl returns ENOTTY is how the application can tell that the input isn't a terminal. It's expected. Just because a function returns an error status doesn't mean that something is wrong.

You must log in to answer this question.