I disagree with Corona688. Being in the foreground or background shouldn't affect what ioctl's a device supports.
It is my belief that the cause of the malfunction is that STDIN is not a terminal because the shell is redirecting STDIN from /dev/null when it runs the process (or pipeline) in the background.
I don't know what system you're running, but on a circa 2007 Debian Linux install, /usr/include/asm-generic/errno-base.h (which is the ultimate destination of the #include breadcrumb trail beginning at /usr/include/errno.h) has this to say:
Yes I too agree with alister...only a foreground process can read from the terminal preventing multiple processes from competing for terminal input as there's only one process in the foreground at any instant...
You can call it in the background, but to keep the tty as standard input requires overriding the shell's redirection. Note that if the process tries to read while not in the foreground process group, it will be signaled and put to sleep.
Not knowing what you are trying to achieve, it's impossible to say if I just gave you good or bad advice. Still, I wanted to mention that it is possible to workaround this ENOTTY.
My script calls the program to suspend console timeout. Issue seen when program run in background in script. What I have to modify in the script to avoid the issue. How to override the shell's redirectrion to tty?