Bug 64658 - kbdrate doesn't work when run inside apmcontinue
Summary: kbdrate doesn't work when run inside apmcontinue
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: kbd
Version: 7.3
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Eido Inoue
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-05-09 08:32 UTC by dellaric
Modified: 2007-04-18 16:42 UTC (History)
1 user (show)

Fixed In Version: 1.12-1
Clone Of:
Environment:
Last Closed: 2004-02-27 01:41:53 UTC
Embargoed:


Attachments (Terms of Use)

Description dellaric 2002-05-09 08:32:41 UTC
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.

Comment 1 dellaric 2002-05-09 20:00:03 UTC
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 14:22:33 UTC
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 19:39:06 UTC
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 

Comment 4 Eido Inoue 2004-02-27 01:41:53 UTC
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.