Hi all, Special thanks to Casper for his guidance.OK, then we just modify the getresponse () function as below:
******************************************************************************************** char *getresponse(char *oldval) { char resp[MAX_INPUT_LEN]; char *retval = NULL; int resplen; int c; c=getchar(); if(c==EOF) { fprintf(stderr,MSG_CTRL); passwd_exit(CTRLD); } else { (void) fgets(resp, sizeof (resp) - 1, stdin); resplen = strlen(resp) - 1; if (resp[resplen] == '\n') resp[resplen] = '\0'; if (*resp != '\0' && strcmp(resp, oldval) != 0) retval = strdup(resp); return (retval); } } ************************************************************************************************ And now, we just change the macro MSG_CTRL to #define MSG_CTRL "\nYou have typed Ctrl-D which is unacceptable\n" ************************************************************************************************ The other macro CTRLD remains the same. #define CTRLD 11 /*Exit value for typing Ctrl-D*/ ************************************************************************************************* Now when we type 'passwd -e' in the shell and when prompted for a new shell, we type Ctrl-D, the output is You have pressed or Ctrl-D which is unacceptable. Login shell unchanged. ************************************************************************************************* Hope this solves the bug. Regards, Samir Kumar Mishra 3rd year , Electronics and Telecommunication Engg. UCE, Burla(India) On 12/28/07, Casper.Dik at sun.com <Casper.Dik at sun.com> wrote: > > >Hi Carol, > > > >Now , I have come to know that Ctrl-D doesnot generate a signal but signals > EOF. > >So , i made the following changes in the code again. > > > >************************************************************************************************* > > > >char *getresponse(char *oldval) > > { > > char resp[MAX_INPUT_LEN]; > > char *retval = NULL; > > int resplen; > > char c; > > c=getchar(); > > getchar() returns an "int" and so "c" must be of type "int". > > > Casper > >