[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-readline] readline spins up at 100% CPU when put into background fr

From: Cook, Rich
Subject: [Bug-readline] readline spins up at 100% CPU when put into background from shell script
Date: Wed, 12 Sep 2012 00:18:12 +0000

I have a problem which I believe is in readline. The problem shows up in the 
readline library, and is in two different programs each of which use readline. 

I'm not sure what version of readline we have.  I see: 
and in /usr/include/readline/readline.h: 
/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION     0x0600          /* Readline 6.0 */
#define RL_VERSION_MAJOR        6
#define RL_VERSION_MINOR        0

What happens is the following.  I write a wrapper script for, say, gnuplot, 
let's make it real simple for analysis' sake. The actual script does more than 
this, but this script exhibits the problem I'm having and is very simple:  

#!/usr/bin/env bash
 /usr/local/tools/gnuplot-4.4.3/bin/gnuplot.real "$@"

Easy peasy!  When this script is run, then put into the background with 
Control-Z, readline goes "berserk" taking up 100% of a CPU trying to read a 
keystroke.  A trace trap shows this:  

Stack Trace
    tcsetattr,           FP=7fffffffd060
    rl_tty_unset_default_bindings, FP=7fffffffd080
    rl_deprep_terminal,  FP=7fffffffd090
    rl_cleanup_after_signal, FP=7fffffffd0a0
    rl_reset_after_signal, FP=7fffffffd140
    rl_read_key,         FP=7fffffffd160
    readline_internal_char, FP=7fffffffd180
    readline,            FP=7fffffffd190
C    read_line,           FP=7fffffffd1e0
C    com_line,            FP=7fffffffd1f0
C    main,                FP=7fffffffd3e0
    __libc_start_main,   FP=7fffffffd4a0
    _start,              FP=7fffffffd4b0

This only happens when gnuplot is backgrounded from a script.  If I run gnuplot 
binary from the command line directly it does not exhibit this problem. 

Can someone on this list comment or suggest steps I could take to solve this?  
For now I have a workaround to call 
exec /usr/local/tools/gnuplot-4.4.3/bin/gnuplot.real "$@"

But I am using "trap" in my script to get signals and calling exec defeats all 
my signal handling traps. 

✐Richard Cook   
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557        
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605    
☎ (fax) (925) 423-6961
Information Management & Graphics Grp., Services & Development Div., Integrated 
Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]