Skip to content

sapi/cli: setting process name little optimisation. #14767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sapi/cli/ps_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* The following code is adopted from the PostgreSQL's ps_status(.h/.c).
*/

#include <php.h>
#ifdef PHP_WIN32
#include "config.w32.h"
#include <windows.h>
Expand Down Expand Up @@ -342,9 +343,8 @@ int set_ps_title(const char* title)
if (rc != PS_TITLE_SUCCESS)
return rc;

strncpy(ps_buffer, title, ps_buffer_size);
ps_buffer[ps_buffer_size - 1] = '\0';
ps_buffer_cur_len = strlen(ps_buffer);
size_t title_len = strlcpy(ps_buffer, title, ps_buffer_size);
ps_buffer_cur_len = (title_len >= ps_buffer_size) ? ps_buffer_size - 1 : title_len;

#ifdef PS_USE_SETPROCTITLE
setproctitle("%s", ps_buffer);
Expand Down
Loading