Skip to content

PermissionError: [Errno 1] Operation not permitted #43

Open
@chinghwayu

Description

@chinghwayu

When connecting with madbg client, the script dies and return with this error.

Stack trace:

  File ".../site-packages/madbg/api.py", line 57, in sigio_handler
    debugger, debugger_exit_stack = use_context(RemoteIPythonDebugger.start_from_new_connection(sock))
  File ".../site-packages/madbg/utils.py", line 34, in use_context
    context_value = exit_stack.enter_context(context_manager)
  File "/usr/lib/python3.8/contextlib.py", line 425, in enter_context
    result = _cm_type.__enter__(cm)
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File ".../site-packages/madbg/debugger.py", line 170, in start_from_new_connection
    with cls.start(sock.fileno()) as debugger:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File ".../site-packages/madbg/debugger.py", line 133, in start
    pty.make_ctty()
  File ".../site-packages/madbg/tty_utils.py", line 120, in make_ctty
    detach_current_ctty()
  File ".../site-packages/madbg/tty_utils.py", line 85, in detach_current_ctty
    make_session_leader()
  File ".../site-packages/madbg/tty_utils.py", line 33, in make_session_leader
    os.setsid()
PermissionError: [Errno 1] Operation not permitted

I wrote a simple test:

import os

if __name__ == '__main__':
    try:
        os.setsid()
    except OSError as e:
        print(f"os.setsid failed: {e}")
        print(f"pid={os.getpid()}  pgid={os.getpgid(0)}")

Result:

os.setsid failed: [Errno 1] Operation not permitted
pid=132918  pgid=132918

Why does this happen and how do I resolve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions