Looking at sys/proc_internal.h in xnu-1699.24.23, I find that PID_MAX is 99999. The value is used in kern_fork.c in the function forkproc. Looking at that function, process IDs are not assigned equal to PID_MAX, so the highest possible pid is 99998.
Occasionally in Mac OS X, it may be necessary to force a program or process to quit. For example, if a particular program fails to respond or unexpectedly hangs. Every application on a Mac comprises of one or more processes.
Probably the most useful tool to check and kill processes is called Terminal, which is an application that provides access to the lower levels of the Mac OS X operating system and files. Terminal is a text-based tool which lets you conduct all manner of routine tasks such as viewing directories, copying, moving and deleting files, as well as obtain detailed information about each process running including:
Each application on your Mac has an associated Process ID (a PID) and a user-friendly name. From here you can inspect or quit each process, but in this example we use Activity Monitor simply as a companion to Terminal.
The first step is to open Terminal either from the Applications -> Utilities folder or simply type Terminal into Spotlight. Terminal is always represented by the icon below.
The first line shows the date and time when you last logged in. The second line is the command prompt which is where you enter the commands you wish to execute . The command prompt always begins with your computer name followed by your local Account Name.
Note that many commands in Terminal can accept various options (sometimes called switches) that can alter their effect. The simplest way to discover the available command-line options is to type the command into Terminal followed by -? such as ls -?
One very useful command to help find a process by name or PID is grep which can filter out the desired information. It can be used in conjunction with the ps -ax command to list only the process that you are interested in.
Caution: killall should be used sparingly to avoid accidentally terminating the wrong processes. There is no confirmation prompt to ask if you really do wish to kill the processes, so check carefully beforehand.
CleanMyMac is highest rated all-round cleaning app for the Mac, it can quickly diagnose and solve a whole plethora of common (but sometimes tedious to fix) issues at the click of a button. It also just happens to resolve many of the issues covered in the speed up section of this site, so Download CleanMyMac to get your Mac back up to speed today.
I've been passionate about Apple ever since I bought my first iPod followed by a white polycarbonate MacBook in 2007. I currently own a MacBook Pro Retina, an iPad Mini Retina, and an iPhone 6. Roland's Google Profile
The effect is dramatic and immediate, going from the boring old fields of text to an easier to scan and easier to act on list, showing the associated app icon when possible, bold process names, and perhaps most useful at all, the PID of the associated sender/process that is displaying in Console logs.
The Console is nomplete with an actionable PID (perfect for quickly force quitting those problematic apps), a bold sender name, and the sender icons (for GUI apps, not all processes and daemons will have an associated icon to display).
When your Mac slows down or starts behaving erratically, chances are it's because an application that's running, perhaps in the background, is misbehaving. And if it's not an application that's causing the problem, it will almost certainly be a process associated with macOS or an ancillary service.
The easiest way to view all active processes running on your Mac is to launch Activity Monitor from your Applications folder. In the default CPU tab, you can see how much processing power every process takes, ranked by the most consuming. And if you switch to the Memory tab, you will see the same list ranked by the amount of used up RAM.
For more immediate information on how your computer resources are consumed, check running process in Mac using iStat Menus, which handily lives in your menu bar and, in its MEM table, shows you applications and processes that are consuming more than their fair share of RAM in real time.
Open Activity Monitor. The fastest way is to open Activity Monitor through iStat Menus. Alternatively, press Command and spacebar to call up Spotlight, then start typing Activity Monitor. When it appears in Spotlight, hit Return to launch it.
View and filter tasks. You'll notice there are five tabs across the top of the Activity Monitor window: CPU, Energy, Memory, Disk, and Network. Clicking on any of those tabs organizes processes according to the percentage of the resource they are using. So, clicking on CPU lists tasks in the order of how much CPU capacity they're using. By default, processes are ordered starting with the one that's consuming the most of the resource at the top, so you can quickly see where problems are occurring or likely to occur. To flip the order, so that processes consuming the least of the resource are at the top, click the arrow next to Memory or CPU above the list of processes.
Kill problematic processes. When you identify a process that's causing a problem, either because it's hogging lots of CPU cycles or memory, or because it's highlighted in the Activity Monitor as having crashed, you need to kill it. To do that, click on the process first and then on the X in the Activity Monitor toolbar. The process will quit and free up the resources it was taking up. If it's a critical process, it will restart. If it's an application, it will remain shut down.
Kill an unwanted process. When you identify a process that's causing a problem or consuming too many resources, take note of the number in the PID column next to the name of the process. To kill the process, type "kill -9" followed by the PID number. Press Enter. The problem process will now quit.
You can pretty much avoid issues altogether by being a little bit proactive in hunting down the common culprits. With iStat Menus, you can quickly identify which applications or processes are consuming finite resources, such as CPU and RAM. And CleanMyMac X will help you run regular maintenance tasks to keep your Mac running smoothly:
Run other tasks, as necessary. If you're having problems with Mail, repeat step 3, but this time click the checkbox next to Speed Up Mail. Likewise, if Spotlight is running slowly, run the Reindex Spotlight task.
Another Mac force kill process solution is Activity Monitor. While the steps are the same as described in the "How to kill a running process using Activity Monitor" section above, the key difference is that background processes often have obscure names that don't clearly describe what they do.
Be careful when killing a background process with Activity Monitor and, if not sure, leave it alone or search online for its exact role in your system. Otherwise, you might risk causing problems for your macOS. Generally, background processes don't tend to consume significant RAM or CPU cycles, so if you spot one that does, it has probably got into trouble. Kill it using the X in the Activity Monitor toolbar.
If resetting the app doesn't work, the final resort should be to uninstall the app completely and reinstall it. To do that, click Complete Uninstallation in the same menu instead of Application Reset.
One common cause of Macs running slowly or having problems is items that launch automatically at startup. These could be helper apps for something like iTunes or just complete apps in their own right. They are also frequently apps you once used but no longer need.
As you can see there are lots of different ways and apps that help you view and kill processes in macOS. iStat Menus is a great way to monitor which processes are causing problems, so you can launch Activity Monitor and quit them. Quit All is a great solution to force quit processes and background apps. Finally, running maintenance scripts in CleanMyMac X regularly prevents problems occurring in the first place. Best of all, all these apps are available to try for free on Setapp, along with over 230 high-quality Mac and iPhone apps.
But in our case the port parameter should not be appended at the end of our alias. So what we have to do to get around this is to first wrap the command in a function and then create an alias to that function:
In Unix-like operating systems, new processes are created by the fork() system call. The PID is returned to the parent process, enabling it to refer to the child in further function calls. The parent may, for example, wait for the child to terminate with the waitpid() function, or terminate the process with kill().
There are two tasks with specially distinguished process IDs: swapper or sched has process ID 0 and is responsible for paging, and is actually part of the kernel rather than a normal user-mode process. Process ID 1 is usually the init process primarily responsible for starting and shutting down the system. Originally, process ID 1 was not specifically reserved for init by any technical measures: it simply had this ID as a natural consequence of being the first process invoked by the kernel. More recent Unix systems typically have additional kernel components visible as 'processes', in which case PID 1 is actively reserved for the init process to maintain consistency with older systems. 2b1af7f3a8