相关疑难解决方法(0)

Readline:获取SIGINT的新提示

我使用readline获得了类似于以下内容的代码:

#include <errno.h>
#include <error.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <readline/readline.h>
#include <readline/history.h>

void handle_signals(int signo) {
  if (signo == SIGINT) {
    printf("You pressed Ctrl+C\n");
  }
}

int main (int argc, char **argv)
{
   //printf("path is: %s\n", path_string);
  char * input;
  char * shell_prompt = "i-shell> ";
  if (signal(SIGINT, handle_signals) == SIG_ERR) {
    printf("failed to register interrupts with kernel\n");
  }

  //set up custom completer and associated data strucutres
  setup_readline();

  while (1) 
  {
    input = …
Run Code Online (Sandbox Code Playgroud)

c signals readline sigint

12
推荐指数
3
解决办法
4989
查看次数

标签 统计

c ×1

readline ×1

sigint ×1

signals ×1