Skip to content

Commit

Permalink
[#21381] Tools: Set LC_ALL=C.UTF-8 when running pgrep in yb-ctl
Browse files Browse the repository at this point in the history
Summary:
When other processes have UTF-8 characters in their names, pgrep may fail
due to expecting a different encoding.

This revision fixes the issue by setting
the `LC_ALL` environment variable to `C.UTF-8` when invoking `pgrep`. Note that
the environment variable is only set for the subprocess which `pgrep` runs in;
this change does not modify it anywhere else.
Jira: DB-10275

Test Plan:
```
bin/yb-ctl create
```

Reviewers: mbautin

Reviewed By: mbautin

Differential Revision: https://phorge.dev.yugabyte.com/D33008
  • Loading branch information
kai-franz committed Mar 11, 2024
1 parent 1419d93 commit 6419423
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/installation/bin/yb-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ class ClusterControl:
pgrep_full_command_output_arg = '--list-full'
pgrep_regex_str = self.get_pgrep_regex(daemon_id)
pgrep_output = subprocess.check_output(
["pgrep", pgrep_full_command_output_arg, "-f", pgrep_regex_str]
["pgrep", pgrep_full_command_output_arg, "-f", pgrep_regex_str],
env={"LC_ALL": "C.UTF-8"}
).strip().decode('utf-8')

data_dirs_re_match = FS_DATA_DIRS_ARG_RE.search(pgrep_output)
Expand Down

0 comments on commit 6419423

Please sign in to comment.