Bug 130899 - Incorrect save state for the "I" option in saved ~/.toprc
Summary: Incorrect save state for the "I" option in saved ~/.toprc
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: procps
Version: 3.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2004-08-25 17:00 UTC by Pancrazio `ezio' de Mauro
Modified: 2007-11-30 22:07 UTC (History)
1 user (show)

Clone Of:
Last Closed: 2004-11-18 07:59:14 UTC

Attachments (Terms of Use)

Description Pancrazio `ezio' de Mauro 2004-08-25 17:00:50 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7)
Gecko/20040803 Firefox/0.9.3

Description of problem:
The "I" option in top, used to toggle Irix mode, is icorrectly saved
and restored from ~/.toprc, causing Irix mode to flip-flop every time
top is run.

This is how to reproduce the problem:

1) $ rm ~/.toprc
2) $ top
3) Save the current configuration pressing the W key
4) Quit top pressing the q key
5) ~/.toprc contains the I option even if it shouldn't!
6) run top again
7) Save the current configuration pressing the W key
8) Quit top pressing the q key
9) Now ~/.toprc does not contain I anymore!

So the I option was toggled withtout the user's intervention.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Please see above

Actual Results:  Please see above

Expected Results:  Please see above

Additional info:

This is what happens:

in the source code for top, here is the "save options" code (top.c
line 1987):

       if (!Irixmode)
               fprintf(fp, "%c", 'I');

and this is the "parse options" code (top.c line 221):

       case 'I':
               Irixmode = 1;

in other words, "I" is saved to the file if the Irixmode variable is
false. At the same time, Irixmode is set to true if "I" is found in
the configuration file, and this leads to the unwanted toggling.

This can be fixed at least in two ways.

The two possibilities I can think of are either (file names and line
numbers refer to pristine source code + spec patches applied):

       top.c line 1987: "if(!Irixmode)" becomes "if(Irixmode)"


       top.c line 222: "Irixmode = 1" becomes "Irixmode = 0"

This last option is probably preferable and it would mean undoing the
second chunk in procps-2.0.13-noirixmode.patch which says:

       --- procps-2.0.13/top.c.irixmode        2003-09-23
12:26:28.000000000 +0200
       +++ procps-2.0.13/top.c 2003-09-23 12:26:32.000000000 +0200
       @@ -219,7 +219,7 @@
                       case '\n':
                       case 'I':
       -                       Irixmode = 0;
       +                       Irixmode = 1;
                               fprintf(stderr, "Wrong configuration
option %c\n", i);

and it was probably introduced by mistake with the noirixmode patch.

Comment 1 Daniel Walsh 2004-08-30 19:37:27 UTC
Have you looked at procps-2.0.17-10
  It seems to have this fixed.   It is in U3.


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