This commit is contained in:
Jim Meyering
1993-12-28 21:18:17 +00:00
parent 2db44d14e4
commit 704a7eba4a
3 changed files with 27 additions and 17 deletions
+1 -1
View File
@@ -270,7 +270,7 @@ FORMAT controls the output. Interpreted sequences are:\n\
%%r time, 12-hour (hh:mm:ss [AP]M)\n\
%%s seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension)\n\
%%t a horizontal tab\n\
%%w day of week (0..6)\n\
%%w day of week (0..6); 0 represents Sunday\n\
%%x locale's date representation (mm/dd/yy)\n\
%%y last two digits of year (00..99)\n\
");
+8 -1
View File
@@ -182,8 +182,15 @@ tee (nfiles, files)
}
}
while ((bytes_read = read (0, buffer, sizeof buffer)) > 0)
while (1)
{
bytes_read = read (0, buffer, sizeof buffer);
#ifdef EINTR
if (bytes_read < 0 && errno == EINTR)
continue;
#endif
if (bytes_read <= 0)
break;
xwrite (1, buffer, bytes_read);
for (i = 0; i < nfiles; i++)
if (descriptors[i] != -1)
+18 -15
View File
@@ -195,9 +195,6 @@ main (argc, argv)
if (show_help)
usage (0);
if (chdir ("/dev"))
error (1, errno, "cannot change directory to /dev");
switch (argc - optind)
{
case 0: /* who */
@@ -249,27 +246,27 @@ static int
read_utmp (filename)
char *filename;
{
register int desc;
FILE *utmp;
struct stat file_stats;
int n_read;
desc = open (filename, O_RDONLY, 0);
if (desc < 0)
utmp = fopen (filename, "r");
if (utmp == NULL)
error (1, errno, "%s", filename);
fstat (desc, &file_stats);
fstat (fileno (utmp), &file_stats);
if (file_stats.st_size > 0)
utmp_contents = (STRUCT_UTMP *) xmalloc ((unsigned) file_stats.st_size);
else
{
close (desc);
fclose (utmp);
return 0;
}
/* Use < instead of != in case the utmp just grew. */
if (read (desc, utmp_contents, file_stats.st_size) < file_stats.st_size)
error (1, errno, "%s", filename);
if (close (desc) != 0)
n_read = fread (utmp_contents, 1, file_stats.st_size, utmp);
if (ferror (utmp) || fclose (utmp) == EOF
|| n_read < file_stats.st_size)
error (1, errno, "%s", filename);
return file_stats.st_size / sizeof (STRUCT_UTMP);
@@ -284,10 +281,16 @@ print_entry (this)
struct stat stats;
time_t last_change;
char mesg;
char line[sizeof (this->ut_line) + 1];
strncpy (line, this->ut_line, sizeof (this->ut_line));
line[sizeof (this->ut_line)] = 0;
#define DEV_DIR_WITH_TRAILING_SLASH "/dev/"
#define DEV_DIR_LEN (sizeof (DEV_DIR_WITH_TRAILING_SLASH) - 1)
char line[sizeof (this->ut_line) + DEV_DIR_LEN + 1];
strcpy(line, DEV_DIR_WITH_TRAILING_SLASH);
strncpy (line + DEV_DIR_LEN, this->ut_line, sizeof (this->ut_line));
line[DEV_DIR_LEN + sizeof (this->ut_line)] = '\0';
if (stat (line, &stats) == 0)
{
mesg = (stats.st_mode & S_IWGRP) ? '+' : '-';