title: Readline C: force return of certain text in readline()
body: <p>I am trying to allow an interrupt to cause a certain value to be returned by readline.  Here is a minimal example:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;readline/readline.h&gt;
  
  void handler (int status)
  {
     rl_replace_line("word",0);
     rl_redisplay();
     rl_done = 1;
  }
  
  int main (int argc, char** argv)
  {
     char* entry;
     signal(SIGINT,handler);
     entry = readline("");
  
     printf("\nEntry was: %s\n", entry);
     return 0;
  }
  </code></pre>
  
  <p>If I run this code and press Control-C, after I hit ENTER, sure enough it prints "Entry was: word".  But I would like it to do so without the user needing to press ENTER.  I basically just want to set entry to "word" when the interrupt signal is received, ending the readline function.  I have been unable to find any documentation for how to just end the readline loop and return a certain value (I'm sure it's out there, but I haven't found it).</p>
  
  <p>One thing I tried was adding </p>
  
  <pre><code> (*rl_named_function("accept-line"))(1,0);
  </code></pre>
  
  <p>at the end of handler, but it didn't send the text to "entry" immediately. </p>