- if (histty[0]==0) {
- strcpy(histty, "/dev/");
- strcat(histty, ubuf.ut_line);
+ if (histty[0]==0 || nomesg && histtya == 0) {
+ strcpy(ttybuf, "/dev/");
+ strcat(ttybuf, ubuf.ut_line);
+ if (histty[0]==0)
+ strcpy(histty, ttybuf);
+ if (access(ttybuf, 0) < 0 || stat(ttybuf, &stbuf) < 0 ||
+ (stbuf.st_mode&020) == 0)
+ nomesg++;
+ else {
+ strcpy(histty, ttybuf);
+ nomesg = 0;
+ }