From Bugzilla Helper: User-Agent: Mozilla/4.78 [en] (X11; U; OSF1 V4.0 alpha) Description of problem: kbdrate -d 250 -r 30 fails when run inside apmcontinue with apmd-3.0.2-10 Version-Release number of selected component (if applicable): apmd-3.0.2-10 How reproducible: Always Steps to Reproduce: 1. compile and install apmd 3.0.2-10 with #define APM_TRACE 5 2. add kbdrate -d 250 -r 30 to /etc/sysconfig/apm-scripts/apmcontinue 3. suspend 4. resume 5. check in /var/log/messages for 'ioctl(KDKBDREP): Inappropriate ioctl for device' Actual Results: kbdrate -d 250 -r 30 fails when run inside apmscript/apmcontinue with apmd-3.0.2-10 if compiled with #define APM_TRACE 5, kbdrate shows the error 'ioctl(KDKBDREP): Inappropriate ioctl for device' inside /var/log/messages Expected Results: kbdrate -d 250 -r 30 should work when run inside apmscript/apmcontinue, it is working smoothly when using apmd-3.0final-34 Additional info: if I comment out in apmd.c from apmd-3.0.2-10 the following lines: /* don't let them inherit stdin. Use /dev/null instead. */ close(0); open("/dev/null", O_RDONLY); then kbdrate works again. I guess that kbdrate needs access to stdin to work.
Looking at /etc/init.d/keytable, I've seen this line: loadkeys $KEYTABLE < /dev/tty0 > /dev/null 2>&1 I've modified my /etc/sysconfig/apm-scripts/apmcontinue to use kbdrate -d 250 -r 30 < /dev/tty0 instead of the old kbdrate -d 250 -r 30 and now kbdrate works correctly.
I can reproduce this problem from the command line with bash -c 'kbdrate&' IMO, kbdrate shouldn't require a terminal to work properly. Also, in 7.3 running kbdrate from a console always sets the repeat rate to 33.3cps, delay 250ms, regardless of the arguments I specify. Running it from an xterm works fine.
I'm not using RedHat but Debian instead. Nevertheless, on Debian exists the same problem. I changed the source of kbdrate to fix it, here is a patch for kbdrate.c: --- ../kbdrate/kbd-1.06/src/kbdrate.c.orig 2003-09-27 01:24:20.000000000 +0200 +++ ../kbdrate/kbd-1.06/src/kbdrate.c 2003-09-27 01:19:29.000000000 +0200 @@ -105,7 +105,7 @@ kbdrep_s.rate = -1; kbdrep_s.delay = -1; if (ioctl( 0, KDKBDREP, &kbdrep_s )) { - if (errno == EINVAL) + if ((errno == EINVAL) || (errno == ENOTTY)) return 0; perror( "ioctl(KDKBDREP)" ); exit( 1 ); As you can see, kbdrate crashes if no tty is available, but there is no reason for it. Just catching this error works fine (at least for me) Hope that helps
patch to output to stderr rather than crash and output to messages log is in kbd 1.12