SCCS-vsn: bin/ps/ps.c 4.32
-static char *sccsid = "@(#)ps.c 4.31 (Berkeley) %G%";
+static char *sccsid = "@(#)ps.c 4.32 (Berkeley) %G%";
char *tptr;
char *gettty(), *getcmd(), *getname(), *savestr(), *state();
char *rindex(), *calloc(), *sbrk(), *strcpy(), *strcat(), *strncat();
char *tptr;
char *gettty(), *getcmd(), *getname(), *savestr(), *state();
char *rindex(), *calloc(), *sbrk(), *strcpy(), *strcat(), *strncat();
-char *strncpy(), *index(), *ttyname(), mytty[16];
+char *strncpy(), *index(), *ttyname(), mytty[MAXPATHLEN+1];
long lseek();
off_t vtophys();
double pcpu(), pmem();
long lseek();
off_t vtophys();
double pcpu(), pmem();
case 't':
if (*ap)
tptr = ap;
case 't':
if (*ap)
tptr = ap;
- else if ((tptr = ttyname(2)) != 0) {
- strcpy(mytty, tptr);
- if ((tptr = index(mytty,'y')) != 0)
- tptr++;
+ else if ((tptr = ttyname(0)) != 0) {
+ tptr = strcpy(mytty, tptr);
+ if (strncmp(tptr, "/dev/", 5) == 0)
+ tptr += 5;
+ if (strncmp(tptr, "tty", 3) == 0)
+ tptr += 3;
aflg++;
gflg++;
if (tptr && *tptr == '?')
aflg++;
gflg++;
if (tptr && *tptr == '?')
- if (sp->ap->a_flag & SWEXIT)
- printf(" <exiting>");
- else if (sp->ap->a_stat == SZOMB)
+ if (sp->ap->a_stat == SZOMB)
+ else if (sp->ap->a_flag & SWEXIT)
+ printf(" <exiting>");
else if (sp->ap->a_pid == 0)
printf(" swapper");
else if (sp->ap->a_pid == 2)
printf(" pagedaemon");
else if (sp->ap->a_pid == 0)
printf(" swapper");
else if (sp->ap->a_pid == 2)
printf(" pagedaemon");
- else if (sp->ap->a_pid == 3 && sp->ap->a_flag & SSYS)
- printf(" ip input");
else
printf(" %.*s", twidth - cmdstart - 2, sp->ap->a_cmdp);
printf("\n");
else
printf(" %.*s", twidth - cmdstart - 2, sp->ap->a_cmdp);
printf("\n");
int nllen;
register FILE *fp;
int nllen;
register FILE *fp;
setuid(getuid());
if ((fp = fopen(psdb, "w")) == NULL) {
perror(psdb);
setuid(getuid());
if ((fp = fopen(psdb, "w")) == NULL) {
perror(psdb);
if (!kflg)
nl[X_SYSMAP].n_name = "";
nlist(nlistf, nl);
if (!kflg)
nl[X_SYSMAP].n_name = "";
nlist(nlistf, nl);
-" F UID PID PPID CP PRI NI ADDR SZ RSS WCHAN STAT TT TIME";
+" F UID PID PPID CP PRI NI ADDR SZ RSS WCHAN STAT TT TIME";
lpr(sp)
struct savcom *sp;
{
lpr(sp)
struct savcom *sp;
{