SCCS-vsn: usr.bin/write/write.c 4.12
-static char *sccsid = "@(#)write.c 4.11 %G%";
+static char *sccsid = "@(#)write.c 4.12 %G%";
#endif
/*
* write to another user
#endif
/*
* write to another user
histtya = argv[2];
if ((uf = fopen("/etc/utmp", "r")) == NULL) {
perror("write: Can't open /etc/utmp");
histtya = argv[2];
if ((uf = fopen("/etc/utmp", "r")) == NULL) {
perror("write: Can't open /etc/utmp");
+ if (histtya == 0)
+ exit(10);
goto cont;
}
mytty = ttyname(2);
goto cont;
}
mytty = ttyname(2);
- fprintf(stderr, "write: %s not logged in\n", him);
+ fprintf(stderr, "write: %s not logged in%s\n", him,
+ histtya ? " on that tty" : "");
- if (uf != NULL)
- fclose(uf);
if (histtya==0 && logcnt > 1) {
fprintf(stderr,
"write: %s logged in more than once ... writing to %s\n",
him, histty+5);
}
if (histtya==0 && logcnt > 1) {
fprintf(stderr,
"write: %s logged in more than once ... writing to %s\n",
him, histty+5);
}
- if (logcnt == 0) {
- printf(him);
- if (histtya)
- printf(" not on that tty\n");
- else
- printf(" not logged in\n");
- exit(1);
- }
if (access(histty, 0) < 0) {
fprintf(stderr, "write: No such tty\n");
exit(1);
if (access(histty, 0) < 0) {
fprintf(stderr, "write: No such tty\n");
exit(1);