Barely ever seen any 1000 digit PIDs …

This commit is contained in:
Benny Baumann 2020-09-15 22:02:57 +02:00 committed by cgzones
parent 6646030116
commit 6921000481
2 changed files with 3 additions and 3 deletions

View File

@ -52,8 +52,6 @@ void OpenFilesScreen_draw(InfoScreen* this) {
}
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_FileData* fdata = NULL;
OpenFiles_Data* item = &(pdata->data);
@ -76,6 +74,8 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
exit(1);
dup2(fdnull, STDERR_FILENO);
close(fdnull);
char buffer[32] = {0};
xSnprintf(buffer, sizeof(buffer), "%d", pid);
execlp("lsof", "lsof", "-P", "-p", buffer, "-F", NULL);
exit(127);
}

View File

@ -74,7 +74,6 @@ void TraceScreen_draw(InfoScreen* this) {
}
bool TraceScreen_forkTracer(TraceScreen* this) {
char buffer[1001];
int error = pipe(this->fdpair);
if (error == -1) return false;
this->child = fork();
@ -84,6 +83,7 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
dup2(this->fdpair[1], STDERR_FILENO);
int ok = fcntl(this->fdpair[1], F_SETFL, O_NONBLOCK);
if (ok != -1) {
char buffer[32] = {0};
xSnprintf(buffer, sizeof(buffer), "%d", this->super.process->pid);
execlp("strace", "strace", "-T", "-tt", "-s", "512", "-p", buffer, NULL);
}