sarugaku / shellingham

Tool to Detect Surrounding Shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

failing to detect xonsh shell because of `python` process name prefix.

Granitosaurus opened this issue · comments

I'm having issues with xonsh on arch linux 5.5.0.

Shellingham fails to detect the xonsh process as it comes with a python prefix as it's a python program:

$ ps -ww -o "pid=" -o "ppid=" -o "args="                                                                              
   1633    1624 python /usr/bin/xonsh

I've investigated shellingham's code and it seems like the first argument is taken to determine the shell process which in this case is python, where the second argument is the correct one in this case (/usr/bin/xonsh).

It seems that python prefix here is unatural but I can't debug why my machine persists on attaching it. Might be an issue with qtile environment. Thus I'm not sure whether upstream changes are warranted.

Hmm, I’m not sure either. Ideally the upstream can package xonsh as a standalone command (instead of invoking python). It doesn’t even need to be a binary; an executable script with #!python should work.

I could make this an exception as well, since this is definitely a valid way to run the command. Let me sit on this for a couple of days and decide whether it’s a good idea. Thanks for the report!

@uranusjr Thanks, sorry I just sumbitted a PR the same minute you replied.

I've tried all sorts of entry point shebang configurations #!python is invalid and #!/usr/bin/python as well as standard #!/usr/bin/env python add the prefix to processes.

It’s probably due to how Linux (or Arch specifically) invokes the shebang-ed script. If it uses exec (quite likely), the exec-ed process (python /usr/bin/xonsh) would replace the shebang-ed executable (/usr/bin/xonsh), losing that detectable process entirely.

Released as 1.3.2. Thanks for the help!

Cheers and thanks for addressing this! Unfortunately upstream poetry shell command still doesn't work with xonsh though for different reasons - I'll take my fight over there now 😄

It’s probably due to how Linux (or Arch specifically) invokes the shebang-ed script.

It can't be, since we don't do anything whatsoever, we simply redistribute the xonsh project's entry points.

And, I cannot duplicate the reporter's issue, because the process name is always "xonsh" for me.

This is probably because I have python-setproctitle installed, and xonsh avoids saying dependencies are actually required (I'm not sure why) so this can be silently ignored.

xonsh/xonsh#654