### Summary

ansible-core 2.14.3 and 2.14.5 work flawlessly.

ansible-core 2.15.0 does not — the [command](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html) and [shell](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html) modules never return in situations like those described here:

- iiab/iiab#3588

This has been confirmed on both Debian 11 (x86_64 VM) and 64-bit Raspberry Pi OS (Raspberry Pi 400).

Here's an example of ansible 2.15.0 freezing — as a result of the `./start_asterisk start` command (which works perfectly at the command-line, but no longer with ansible 2.15.0) never returning:

![image](https://github.com/ansible/ansible/assets/2458907/f8a0d89b-f038-4730-93d1-f6a0771fc9d7)

### Issue Type

Bug Report

### Component Name

command, shell

### Ansible Version

```console
$ ansible --version    # BAD VERSION

ansible [core 2.15.0]
  config file = /opt/iiab/iiab/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/local/ansible/bin/python3)
  jinja version = 3.1.2
  libyaml = True

$ ansible --version    # GOOD VERSION

ansible [core 2.14.5]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/local/ansible/bin/python3)
  jinja version = 3.1.2
  libyaml = True

$ ansible --version    # GOOD VERSION

ansible [core 2.14.3]
  config file = /opt/iiab/iiab/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] (/usr/local/ansible/bin/python3)
  jinja version = 3.1.2
  libyaml = True
```


### Configuration

```console
$ ansible-config dump --only-changed -t all

CONFIG_FILE() = /opt/iiab/iiab/ansible.cfg
INTERPRETER_PYTHON(/opt/iiab/iiab/ansible.cfg) = /usr/bin/python3

$ cat /opt/iiab/iiab/ansible.cfg

[defaults]
interpreter_python=/usr/bin/python3
```


### OS / Environment

This has been confirmed on both Debian 11 (x86_64 VM) and 64-bit Raspberry Pi OS (Raspberry Pi 400).

### Steps to Reproduce

Install Asterisk and then FreePBX onto Debian 11 as follows:

- https://github.com/iiab/iiab/blob/master/roles/pbx/tasks/asterisk.yml
- https://github.com/iiab/iiab/blob/master/roles/pbx/tasks/freepbx.yml

CLARIF: PHP 7.4 is required, so newer OS's will not work here.

### Expected Results

Running the exact same command at the prompt (Linux command-line) works.

Ansible should not freeze (the command or shell module never complete with 2.15.0 — unlike with 2.14.x).

### Actual Results

Unfortunately there's no error message, as ansible-core 2.15.0 freezes.

Whereas 2.14.3 and 2.14.5 work perfectly.

Please see details at:

- iiab/iiab#3588


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
if self._debug:
            self.log('[debug] %s' % msg)
    def log(self, msg, log_args=None):
        if not self.no_log:
            if log_args is None:
                log_args = dict()
            module = 'ansible-%s' % self._name
            if isinstance(module, binary_type):
                module = module.decode('utf-8', 'replace')
            
            if not isinstance(msg, (binary_type, text_type)):
                raise TypeError("msg should be a string (got %s)" % type(msg))
            
            
            if isinstance(msg, binary_type):
                journal_msg = remove_values(msg.decode('utf-8', 'replace'), self.no_log_values)
            else:
                
                journal_msg = remove_values(msg, self.no_log_values)
            if PY3:
                syslog_msg = journal_msg
            else:
                syslog_msg = journal_msg.encode('utf-8', 'replace')
            if has_journal:
                journal_args = [("MODULE", os.path.basename(__file__))]