Syntax
whoisPID(PID,[cmd])
Input Parameter
PID : | | PID or service name in launched tasks list |
cmd : | | |
Examples
system('launchctl list | grep -v -e ''com.apple''');
whoisPID(540)
whoisPID('com.adobe.GC.AGM')
Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
The function whoisPID
is designed to interact with processes on macOS systems. It takes a process identifier (PID) or a service name and an optional command to perform specific actions.
Input Parameters
- PID: This can be a numeric process ID or a string representing a service name in the list of launched tasks.
- cmd: An optional string parameter that can specify actions like 'remove' or 'unload'.
Algorithm Steps
- Add paths to
/Library/LaunchAgents
and /Library/LaunchDaemons
to the MATLAB search path.
- Retrieve the command parameter using
getfuncparams
function.
- Check if
PID
is numeric:
- If numeric, construct a command string
s
using ps auxww
to get detailed information about the process.
- If
PID
is a string (service name):
- Construct a command string
s
using launchctl list
to list the service.
- Check if
cmd
is 'remove':
- Modify the command string
s
to use launchctl remove
to remove the service.
- Check if
cmd
is 'unload':
- Ensure the
PID
ends with .plist
. If not, append it.
- Find the full path of the
PID
using which
.
- Modify the command string
s
to use launchctl unload
to unload the service.
- Remove the previously added paths from the MATLAB search path.
- Execute the constructed command string
s
using the system
function.
Algorithm explaination created using ChatGPT on 2025-08-19 07:40. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-08-09