Bug 64658 - kbdrate doesn't work when run inside apmcontinue
kbdrate doesn't work when run inside apmcontinue
Product: Red Hat Linux
Classification: Retired
Component: kbd (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Eido Inoue
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2002-05-09 04:32 EDT by dellaric
Modified: 2007-04-18 12:42 EDT (History)
1 user (show)

See Also:
Fixed In Version: 1.12-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-02-26 20:41:53 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description dellaric 2002-05-09 04:32:41 EDT
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):

How reproducible:

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

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. */
        open("/dev/null", O_RDONLY);

then kbdrate works again. I guess that kbdrate needs access to stdin to work.
Comment 1 dellaric 2002-05-09 16:00:03 EDT
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.
Comment 2 Jason Merrill 2002-07-26 10:22:33 EDT
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.
Comment 3 Frederic Gaus 2004-01-11 14:39:06 EST
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
@@ -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 
Comment 4 Eido Inoue 2004-02-26 20:41:53 EST
patch to output to stderr rather than crash and output to messages log
is in kbd 1.12

Note You need to log in before you can comment on or make changes to this bug.