mirror of https://github.com/xzeldon/htop.git
Barely ever seen any 1000 digit PIDs …
This commit is contained in:
parent
6646030116
commit
6921000481
|
@ -52,8 +52,6 @@ void OpenFilesScreen_draw(InfoScreen* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
||||||
char buffer[1025];
|
|
||||||
xSnprintf(buffer, 1024, "%d", pid);
|
|
||||||
OpenFiles_ProcessData* pdata = xCalloc(1, sizeof(OpenFiles_ProcessData));
|
OpenFiles_ProcessData* pdata = xCalloc(1, sizeof(OpenFiles_ProcessData));
|
||||||
OpenFiles_FileData* fdata = NULL;
|
OpenFiles_FileData* fdata = NULL;
|
||||||
OpenFiles_Data* item = &(pdata->data);
|
OpenFiles_Data* item = &(pdata->data);
|
||||||
|
@ -76,6 +74,8 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
||||||
exit(1);
|
exit(1);
|
||||||
dup2(fdnull, STDERR_FILENO);
|
dup2(fdnull, STDERR_FILENO);
|
||||||
close(fdnull);
|
close(fdnull);
|
||||||
|
char buffer[32] = {0};
|
||||||
|
xSnprintf(buffer, sizeof(buffer), "%d", pid);
|
||||||
execlp("lsof", "lsof", "-P", "-p", buffer, "-F", NULL);
|
execlp("lsof", "lsof", "-P", "-p", buffer, "-F", NULL);
|
||||||
exit(127);
|
exit(127);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,6 @@ void TraceScreen_draw(InfoScreen* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TraceScreen_forkTracer(TraceScreen* this) {
|
bool TraceScreen_forkTracer(TraceScreen* this) {
|
||||||
char buffer[1001];
|
|
||||||
int error = pipe(this->fdpair);
|
int error = pipe(this->fdpair);
|
||||||
if (error == -1) return false;
|
if (error == -1) return false;
|
||||||
this->child = fork();
|
this->child = fork();
|
||||||
|
@ -84,6 +83,7 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
|
||||||
dup2(this->fdpair[1], STDERR_FILENO);
|
dup2(this->fdpair[1], STDERR_FILENO);
|
||||||
int ok = fcntl(this->fdpair[1], F_SETFL, O_NONBLOCK);
|
int ok = fcntl(this->fdpair[1], F_SETFL, O_NONBLOCK);
|
||||||
if (ok != -1) {
|
if (ok != -1) {
|
||||||
|
char buffer[32] = {0};
|
||||||
xSnprintf(buffer, sizeof(buffer), "%d", this->super.process->pid);
|
xSnprintf(buffer, sizeof(buffer), "%d", this->super.process->pid);
|
||||||
execlp("strace", "strace", "-T", "-tt", "-s", "512", "-p", buffer, NULL);
|
execlp("strace", "strace", "-T", "-tt", "-s", "512", "-p", buffer, NULL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue