CTRL+C不能終止程式運行

來源:互聯網
上載者:User

用freescale的ltib等工具產生了一個根檔案系統,但是發現在按下 ctrl-c 不能終止程式。
寫一個測試程式

#include <stdio.h>
#include <signal.h>
void sig_handle(int   sig) 

    if(SIGINT==sig) 
    { 
        printf("press again!/n");
    } 
}
 
int main(void)
{
    signal(SIGINT,   sig_handle);
    while(1)
        sleep(10);

    return 0;
}
測試程式沒有列印出press again, 看來是核心沒有把訊號送到當前進程,為什麼呢?
忽然發現在系統啟動時,有一個資訊提示:
/bin/sh: can't access tty; job control turned off
看來題與這個錯誤提示有關,開啟/etc/inittab,其中有一行
::respawn:/bin/sh
把這行改成::respawn:/sbin/getty -L ttymxc0 115200 vt100後就ctrl+c可以工作了,但是登入時需要帳號,密碼。
懶得去研究getty的自動登陸,看了busybox裡的例子,發現加上終端就可以了
ttymxc0::respawn:/bin/sh
其中ttymxc0是串口用的裝置節點名字,有的系統可能是tty1或ttyS1

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.