Skip to content

Weird deadlock (livelock?) in _posix.py when trying to run /usr/bin/env #3

@JarrettBillingsley

Description

@JarrettBillingsley

I've run into this on two totally different versions of sublime text (3 and 4) on two totally different platforms (macOS and Linux) and I seem to be the only one who has so it must be something real weird about my configuration buuuuuuuuut

This line hangs when I try to use an ST package which uses shellenv, such as Rust Enhanced:

https://github.com/codexns/shellenv/blob/master/all/shellenv/_posix.py#L61

The bash process itself hangs, consuming 100% CPU of one core, but not doing any I/O.

I have no idea why this happens, but my workaround was to modify _posix.py to use bash's -c flag instead of writing the command to its standard input:

        if shell_name == 'bash':
            args.append('-i')
            args.append('-c')           # <----------- added
            args.append('/usr/bin/env') # <----------- added

        env_proc = subprocess.Popen(
            args,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT
        )

        if shell_name == 'bash':                                # <------- changed
            stdout, _ = env_proc.communicate()                  # <------- changed
        else:                                                   # <------- changed
            stdout, _ = env_proc.communicate(b'/usr/bin/env\n') # <------- changed

it now works flawlessly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions