1

I'm currently writing a shell, I have several functions implemented but I want to make the Ctrl-D (EOF character) obsolete pretty much. Or at least switch it to a very high number before it actually quits. I'm not really sure how to implement that though. Right now I have:

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
}

I thought maybe just saying somewhere in the loop:

if(feof(stdin))
      continue;

thinking that would just skip it and continue on but that did not work. Any suggestions on how i can get ctrl-d to be ignored? Thanks

VakarianWrex
  • 53
  • 2
  • 9
  • The following answer in the above linked question contains a source example of trapping the EOF signal: http://stackoverflow.com/a/1516414/1553090 – paddy Sep 22 '13 at 23:11
  • Hey sorry for the repost, but thanks guys I got it working! I actually just used an or statement and it worked. So I wrote: while(!feof(stdin) || feof(stdin)) That way it will continue on whether crl-d is pressed or not – VakarianWrex Sep 22 '13 at 23:28

0 Answers0