Skip to content

Commit

Permalink
Merge pull request #15 from themittenmac/ppid-priority-adjustment
Browse files Browse the repository at this point in the history
0.8 code and build updates
  • Loading branch information
jbradley89 authored Aug 23, 2024
2 parents c2b8a2c + 97762f5 commit 126ec1b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Because of the ever changing features on macOS, since macOS 11 some features don
--standard -> Print the standard Unix tree instead of TrueTree
--sources -> Print the source of where each processes parent came from
--nonetwork -> Do not print network connection
--nopid -> Do not print the pid next to each process
--nopath -> Print process name only instead of full paths
--version -> Print the TrueTree version number
-o <filename> -> output to file

Expand Down
14 changes: 11 additions & 3 deletions Src/args.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ class ArgManager {
var sources = false
var timelineMode = true
var network = true
var showpid = true
var showpath = true
var toFile: String?
let availableArgs = ["--nocolor", "--timeline", "--timestamps", "-o", "--standard", "--version", "--sources", "--nonetwork"]
let availableArgs = ["--nocolor", "--timeline", "--timestamps", "-o", "--standard", "--version", "--sources", "--nonetwork", "--nopid", "--nopath"]

init(suppliedArgs: [String]) {
setArgs(suppliedArgs)
Expand All @@ -42,9 +44,13 @@ class ArgManager {
timelineMode.toggle()
} else if arg == "--nonetwork" {
network.toggle()
} else if arg == "--nopid" {
showpid.toggle()
} else if arg == "--nopath" {
showpath.toggle()
} else if arg == "--version" {
print(version)
exit(1)
exit(0)
} else if arg == "-o" {
if args.count > x+1 && !availableArgs.contains(args[x+1]) {
toFile = args[x+1]
Expand All @@ -65,8 +71,10 @@ class ArgManager {
print("--standard Print the standard Unix tree instead of TrueTree")
print("--sources Print the source of where each processes parent came from")
print("--nonetwork Do not print network connection")
print("--nopid Do not print the pid next to each process")
print("--nopath Print process name only instead of full paths")
print("--version Print the TrueTree version number")
print("-o <filename> Output to file")
exit(1)
exit(0)
}
}
2 changes: 1 addition & 1 deletion Src/launchdXPC/launchdXPC.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int getSubmittedPid(int pid) {
long long lo = (temp >> 0) & 0x00000000FFFFFFFFLL;
ProcessSerialNumber parentPSN = {(unsigned long)hi, (unsigned long)lo};

NSDictionary* parentDict = (__bridge NSDictionary*)ProcessInformationCopyDictionary (&parentPSN, kProcessDictionaryIncludeAllInformationMask);
//NSDictionary* parentDict = (__bridge NSDictionary*)ProcessInformationCopyDictionary (&parentPSN, kProcessDictionaryIncludeAllInformationMask);
//NSLog(@"real parent info: %@", parentDict);
//NSLog(@"real parent pid: %@", parentDict[@"pid"]);

Expand Down
6 changes: 3 additions & 3 deletions Src/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

let version = 0.7
let version = 0.8

// Go through command line arguments and set accordingly
let argManager = ArgManager(suppliedArgs:CommandLine.arguments)
Expand Down Expand Up @@ -43,14 +43,14 @@ if argManager.standardMode {
parentNode?.add(child: proc.node)
}
rootNode?.printTree()
exit(1)
exit(0)
}


// If timeline mode is active
if argManager.timelineMode == false {
pc.printTimeline(outputFile: argManager.toFile)
exit(1)
exit(0)
}

// Create a TrueTree
Expand Down
15 changes: 14 additions & 1 deletion Src/node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ final class Node {
let displayString: String
private(set) var children: [Node]

var fileName: String {
if let fileName = path.components(separatedBy: "/").last {
return fileName
}

return path
}

init(_ pid: Int, path: String, timestamp: String, source: String, displayString: String) {
self.pid = pid
self.path = path
Expand Down Expand Up @@ -59,7 +67,12 @@ extension Node {

} else {
if argManager.color {
text = "\(displayString) \(String(pid).magenta)"
if argManager.showpath {
text = "\(displayString)"
} else {
text = "\(fileName)"
}
if argManager.showpid { text += " \(String(pid).magenta)"}
if argManager.timestamps { text += " \(timestamp.cyan)"}
if argManager.sources { text += " Aquired parent from -> \(source)".red }
} else {
Expand Down
5 changes: 4 additions & 1 deletion Src/process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class ProcessCollector {

// Get true parent. Plist parents will be handled elsewhere
let trueParent: Int
if submittedPid > 1 {
if ppid != 1 {
trueParent = ppid
source = "parent_process"
} else if submittedPid > 1 {
trueParent = submittedPid
source = "application_services"
} else if responsiblePid != pid {
Expand Down
12 changes: 6 additions & 6 deletions TrueTree.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,13 @@
CLANG_ENABLE_MODULES = YES;
CLANG_USE_OPTIMIZATION_PROFILE = NO;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = C793NB2B2B;
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
ENABLE_HARDENED_RUNTIME = YES;
INSTALL_PATH = "";
INSTALL_PATH = /usr/local/bin/;
MACOSX_DEPLOYMENT_TARGET = 10.13;
"OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = truetree;
Expand All @@ -328,13 +328,13 @@
CLANG_ENABLE_MODULES = YES;
CLANG_USE_OPTIMIZATION_PROFILE = NO;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = C793NB2B2B;
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
ENABLE_HARDENED_RUNTIME = YES;
INSTALL_PATH = "";
INSTALL_PATH = /usr/local/bin/;
MACOSX_DEPLOYMENT_TARGET = 10.13;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = truetree;
Expand Down

0 comments on commit 126ec1b

Please sign in to comment.