Skip to content

fix: retrieving process name on macOS - #588

Merged
Daniel Imms (Tyriar) merged 1 commit into
mainfrom
robo/fix_proc_name
Mar 31, 2023
Merged

Daniel Imms (Tyriar) merged 1 commit into
mainfrom
robo/fix_proc_name

Conversation

@deepak1556

Copy link
Copy Markdown
Contributor

@deepak1556 Robo (deepak1556) self-assigned this Mar 31, 2023
@deepak1556 Robo (deepak1556) added this to the 1.0.0 milestone Mar 31, 2023
Comment thread src/unix/pty.cc
Comment on lines +680 to +686
pty_getproc(int pid) {
char pname[MAXCOMLEN + 1];
if (!proc_name(pid, pname, sizeof(pname))) {
return NULL;
}

return strdup(kp.kp_proc.p_comm);
return strdup(pname);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is similar to tmux's technique, are we going to regress anywhere by doing it this way? I don't understand how it worked before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went based on the implementation of proc_name which is used in much widely across the kernel code https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/kern/kern_proc.c#L1029-L1044 and it seems reliable.

@Tyriar
Daniel Imms (Tyriar) merged commit 2978b1e into main Mar 31, 2023
@Tyriar
Daniel Imms (Tyriar) deleted the robo/fix_proc_name branch March 31, 2023 17:07
xiaobaidadada pushed a commit to xiaobaidadada/node-pty-prebuilt that referenced this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants