Skip to content

Commit

Permalink
process_control: add extra_options to launch()
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Jan 22, 2024
1 parent 8892853 commit a38ca01
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pymobiledevice3/services/dvt/instruments/process_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import typing

from pymobiledevice3.services.dvt.dvt_secure_socket_proxy import DvtSecureSocketProxyService
from pymobiledevice3.services.remote_server import MessageAux


Expand All @@ -24,7 +25,7 @@ def create(cls, message) -> 'OutputReceivedEvent':
class ProcessControl:
IDENTIFIER = 'com.apple.instruments.server.services.processcontrol'

def __init__(self, dvt):
def __init__(self, dvt: DvtSecureSocketProxyService):
self._channel = dvt.make_channel(self.IDENTIFIER)

def signal(self, pid: int, sig: int):
Expand All @@ -44,23 +45,27 @@ def kill(self, pid: int):
self._channel.killPid_(MessageAux().append_obj(pid), expects_reply=False)

def launch(self, bundle_id: str, arguments=None, kill_existing: bool = True, start_suspended: bool = False,
environment: typing.Mapping = None) -> int:
environment: typing.Mapping = None, extra_options: typing.Mapping = None) -> int:
"""
Launch a process.
:param bundle_id: Bundle id of the process.
:param list arguments: List of argument to pass to process.
:param kill_existing: Whether to kill an existing instance of this process.
:param start_suspended: Same as WaitForDebugger.
:param environment: Environment variables to pass to process.
:param extra_options: Extra options to pass to process.
:return: PID of created process.
"""
arguments = [] if arguments is None else arguments
environment = {} if environment is None else environment
options = {
'StartSuspendedKey': start_suspended,
'KillExisting': kill_existing,
}
if extra_options:
options.update(extra_options)
args = MessageAux().append_obj('').append_obj(bundle_id).append_obj(environment).append_obj(
arguments).append_obj({
'StartSuspendedKey': start_suspended,
'KillExisting': kill_existing,
})
arguments).append_obj(options)
self._channel.launchSuspendedProcessWithDevicePath_bundleIdentifier_environment_arguments_options_(args)
result = self._channel.receive_plist()
assert result
Expand Down

0 comments on commit a38ca01

Please sign in to comment.