ioctl : strace

Hi All,

int ioctl(int d, int request, ...);

Can somebody tell me how does ioctl decides the input parameter: "request".

Sometimes, its SNDCTL_TMR_TIMEBASE or TCGETS
or FIONREAD...etc.

What is the pattern??

I am asking this coz my strace returns this:
open("/usr/lib/perl5/5.8.5/i386-linux-thread-multi/IO/Select.pm", O_RDONLY|O_LARGEFILE) = 5
ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe76d08) = -1 ENOTTY (Inappropriate ioctl for device)

Now, since I have the ioctl error, hence my program is aborting.

Any help!!

I don't understand your question. The programmer who wrote the code set the value of the request.

TCGETS requests a struct termios. It is part of SVR4, not POSIX. Since your process is opening a perl module, not a tty, this is not going to work. Files like a Select.pm - those files are not terminals.

If you wrote this: call isatty() first, if the return is true then

#include <termios.h>
...........
      struct termios original_opts
      int res=0;
      res=tcgetattr(fd, &original_opts);

Save the original_opts, copy to a new struct, then change the terminal settings you want, call tcsetattr with the new_opts struct, then when you are done, call tcsetattr with original_opts to set the term back the way it was. termios is the POSIX way to do this.

What the heck this code dump is showing I don't really know.