pylane icon indicating copy to clipboard operation
pylane copied to clipboard

Fails to check PID in Mac OS

Open die4live opened this issue 6 years ago • 3 comments

image

die4live avatar Feb 19 '19 04:02 die4live

pylane just support Linux and BSD, for mac os, things should be done:

  1. avoid to use /proc to check process
  2. handle gdb codesigned issue in mac os

we will working on them later~

valensc avatar Feb 20 '19 02:02 valensc

pylane just support Linux and BSD, for mac os, things should be done:

  1. avoid to use /proc to check process
  2. handle gdb codesigned issue in mac os

we will working on them later~

I've avoid this issue by modifying the ensure_pid in core/injector.py

121     def ensure_pid(self, pid):
122         """"""
123         sts, pids = subprocess.getstatusoutput("ps | awk 'NR>1{print $1}'")
124         pids = [int(pid) for pid in pids.split('\n')]
125         # if not pid or not os.path.exits('/proc/%s' % pid):
126         if not pid or not pid in pids:
127             raise RequirementsInvalid('Process %s not exist.' % pid)
128         self.pid = pid

However, when run the example presented in Usage with pylane shell <PID>, the following error occurred.

---------------------------------------------------------------------------
NoConnectedClient                         Traceback (most recent call last)
~/.virtualenvs/tf3/bin/pylane in <module>()
      8 if __name__ == '__main__':
      9     sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
---> 10     sys.exit(main())

~/.virtualenvs/tf3/lib/python3.6/site-packages/pylane/entry.py in main()
     42 
     43 def main():
---> 44     main_entry()
     45 
     46 

~/.virtualenvs/tf3/lib/python3.6/site-packages/click/core.py in __call__(self, *args, **kwargs)
    762     def __call__(self, *args, **kwargs):
    763         """Alias for :meth:`main`."""
--> 764         return self.main(*args, **kwargs)
    765 
    766 

~/.virtualenvs/tf3/lib/python3.6/site-packages/click/core.py in main(self, args, prog_name, complete_var, standalone_mode, **extra)
    715             try:
    716                 with self.make_context(prog_name, args, **extra) as ctx:
--> 717                     rv = self.invoke(ctx)
    718                     if not standalone_mode:
    719                         return rv

~/.virtualenvs/tf3/lib/python3.6/site-packages/click/core.py in invoke(self, ctx)
   1135                 sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
   1136                 with sub_ctx:
-> 1137                     return _process_result(sub_ctx.command.invoke(sub_ctx))
   1138 
   1139         # In chain mode we create the contexts step by step, but after the

~/.virtualenvs/tf3/lib/python3.6/site-packages/click/core.py in invoke(self, ctx)
    954         _maybe_show_deprecated_notice(self)
    955         if self.callback is not None:
--> 956             return ctx.invoke(self.callback, **ctx.params)
    957 
    958 

~/.virtualenvs/tf3/lib/python3.6/site-packages/click/core.py in invoke(*args, **kwargs)
    553         with augment_usage_errors(self):
    554             with ctx:
--> 555                 return callback(*args, **kwargs)
    556 
    557     def forward(*args, **kwargs):

~/.virtualenvs/tf3/lib/python3.6/site-packages/click/decorators.py in new_func(*args, **kwargs)
     15     """
     16     def new_func(*args, **kwargs):
---> 17         return f(get_current_context(), *args, **kwargs)
     18     return update_wrapper(new_func, f)
     19 

~/.virtualenvs/tf3/lib/python3.6/site-packages/pylane/entry.py in shell(ctx, pid)
     24 def shell(ctx, pid):
     25     """Create a remote python shell on a process."""
---> 26     _shell(pid=pid, **ctx.obj)
     27 
     28 

~/.virtualenvs/tf3/lib/python3.6/site-packages/pylane/shell/shell.py in shell(*args, **kwargs)
     86 
     87 def shell(*args, **kwargs):
---> 88     return Shell(*args, **kwargs).run()

~/.virtualenvs/tf3/lib/python3.6/site-packages/pylane/shell/shell.py in run(self)
     62         """run shell server and connect"""
     63         shell_proxy = ShellProxy(self.inject_args)
---> 64         shell_proxy.run()
     65         shell_proxy.runsource("print('''%s''')" % self.extend_help)
     66         for pre_code in self.pre_codes:

~/.virtualenvs/tf3/lib/python3.6/site-packages/pylane/shell/proxy.py in run(self)
     71             port=port,
     72             inject_args=self.inject_args)
---> 73         self.wait()
     74 
     75 

~/.virtualenvs/tf3/lib/python3.6/site-packages/pylane/shell/proxy.py in wait(self)
     38         if not self.sock_server.connected():
     39             raise NoConnectedClient(
---> 40                 "No client connected in %s seconds" % self.LISTEN_TIMEOUT
     41             )
     42         self.sock = self.sock_server

NoConnectedClient: No client connected in 30 seconds

Lincoln12w avatar Feb 21 '19 07:02 Lincoln12w

@Lincoln12w does your process output anything or hang up after injection?

you can try gdb directly on your process, just attach and detach. in my case the process just hang up after attach and don't resume after detach.

I'm still looking into it.

valensc avatar Feb 25 '19 03:02 valensc