如何阻止Ctrl-D退出我自己的shell

时间:2013-09-22 23:05:55

标签: c linux shell eof tcsh

我正在编写一个shell,我已经实现了几个函数,但是我想让Ctrl-D(EOF字符)过时了。或者至少在实际退出之前将其切换到非常高的数字。我不确定如何实现它。现在我有:

while(!feof(stdin))
{
    if(fgets (buf, MAX_BUFFER, stdin)) {

    arg = args;
    *arg++ = strtok(buf, SEPERATORS);
    while ((*arg++ = strtok(NULL, SEPERATORS)));

    if (arg[0]) {
        if(!strcmp(args[0], "clr"))
        {
            clr();
            continue;
        }
        //// more commands follow
}

我想也许只是说在循环中的某个地方:

if(feof(stdin))
      continue;

认为只会跳过它并继续,但这不起作用。关于如何让ctrl-d被忽略的任何建议?感谢

0 个答案:

没有答案