There's a tool I use at work to manually test the code we work on. It's a graphical tool written in Java, and it allows us to configure the data for a test. It then runs another process that starts everything up, and then runs another tool to inject a SIP (Session Initiation Protocol) message into the code being tested. It then opens the output file from the SIP injection tool to display the results. This tool doesn't work quite right on Belial, the annoying Mac Laptop [1].
Problem oneāthe output file has, as part of its name, the process ID (Identifier) of the SIP injection tool. And it seems there is no easy way to get said process ID from within Java. The other issue, also related to process IDs, is it attempts to stop the process that starts everything up. That fails, because again, there is no easy way to get a process ID from within Java.
There is code that attempts to get a process ID:
process = pb.start(); if (process.getClass().getName().equals("java.lang.UNIXProcess")) { try { Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true); sippPid = f.getInt(process); } catch (Throwable e) { } }
This horrible bit of code does work under Linux, and it works on older versions of Mac OS-X. But Belial is a more modern version of Mac OS-X, on the new Apple M1 architecture. Here, sippPid is always 0.
Sigh.