Mercurial > emacs
comparison src/process.c @ 100250:41eda8c1e9ca
(procfs_system_process_attributes): If `nread' has a negative value, assign
zero to it.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 05 Dec 2008 16:44:56 +0000 |
parents | 44b480d7a129 |
children | d698608b3a92 |
comparison
equal
deleted
inserted
replaced
100249:8cc99245d731 | 100250:41eda8c1e9ca |
---|---|
7432 cmdline = xmalloc (cmdline_size + 1); | 7432 cmdline = xmalloc (cmdline_size + 1); |
7433 lseek (fd, 0L, SEEK_SET); | 7433 lseek (fd, 0L, SEEK_SET); |
7434 cmdline[0] = '\0'; | 7434 cmdline[0] = '\0'; |
7435 if ((nread = read (fd, cmdline, cmdline_size)) >= 0) | 7435 if ((nread = read (fd, cmdline, cmdline_size)) >= 0) |
7436 cmdline[nread++] = '\0'; | 7436 cmdline[nread++] = '\0'; |
7437 else | |
7438 { | |
7439 /* Assigning zero to `nread' makes us skip the following | |
7440 two loops, assign zero to cmdline_size, and enter the | |
7441 following `if' clause that handles unknown command | |
7442 lines. */ | |
7443 nread = 0; | |
7444 } | |
7437 /* We don't want trailing null characters. */ | 7445 /* We don't want trailing null characters. */ |
7438 for (p = cmdline + nread - 1; p > cmdline && !*p; p--) | 7446 for (p = cmdline + nread - 1; p > cmdline && !*p; p--) |
7439 nread--; | 7447 nread--; |
7440 for (p = cmdline; p < cmdline + nread; p++) | 7448 for (p = cmdline; p < cmdline + nread; p++) |
7441 { | 7449 { |
7449 else if (*p == '\0') | 7457 else if (*p == '\0') |
7450 *p = ' '; | 7458 *p = ' '; |
7451 } | 7459 } |
7452 cmdline_size = nread; | 7460 cmdline_size = nread; |
7453 } | 7461 } |
7454 else | 7462 if (!cmdline_size) |
7455 { | 7463 { |
7456 if (!cmd) | 7464 if (!cmd) |
7457 cmd = "???"; | 7465 cmd = "???"; |
7458 if (!cmdsize) | 7466 if (!cmdsize) |
7459 cmdsize = strlen (cmd); | 7467 cmdsize = strlen (cmd); |