Skip to content

Commit 126ec1b

Browse files
authored
Merge pull request #15 from themittenmac/ppid-priority-adjustment
0.8 code and build updates
2 parents c2b8a2c + 97762f5 commit 126ec1b

File tree

7 files changed

+41
-15
lines changed

7 files changed

+41
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Because of the ever changing features on macOS, since macOS 11 some features don
1818
--standard -> Print the standard Unix tree instead of TrueTree
1919
--sources -> Print the source of where each processes parent came from
2020
--nonetwork -> Do not print network connection
21+
--nopid -> Do not print the pid next to each process
22+
--nopath -> Print process name only instead of full paths
2123
--version -> Print the TrueTree version number
2224
-o <filename> -> output to file
2325

Src/args.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class ArgManager {
1717
var sources = false
1818
var timelineMode = true
1919
var network = true
20+
var showpid = true
21+
var showpath = true
2022
var toFile: String?
21-
let availableArgs = ["--nocolor", "--timeline", "--timestamps", "-o", "--standard", "--version", "--sources", "--nonetwork"]
23+
let availableArgs = ["--nocolor", "--timeline", "--timestamps", "-o", "--standard", "--version", "--sources", "--nonetwork", "--nopid", "--nopath"]
2224

2325
init(suppliedArgs: [String]) {
2426
setArgs(suppliedArgs)
@@ -42,9 +44,13 @@ class ArgManager {
4244
timelineMode.toggle()
4345
} else if arg == "--nonetwork" {
4446
network.toggle()
47+
} else if arg == "--nopid" {
48+
showpid.toggle()
49+
} else if arg == "--nopath" {
50+
showpath.toggle()
4551
} else if arg == "--version" {
4652
print(version)
47-
exit(1)
53+
exit(0)
4854
} else if arg == "-o" {
4955
if args.count > x+1 && !availableArgs.contains(args[x+1]) {
5056
toFile = args[x+1]
@@ -65,8 +71,10 @@ class ArgManager {
6571
print("--standard Print the standard Unix tree instead of TrueTree")
6672
print("--sources Print the source of where each processes parent came from")
6773
print("--nonetwork Do not print network connection")
74+
print("--nopid Do not print the pid next to each process")
75+
print("--nopath Print process name only instead of full paths")
6876
print("--version Print the TrueTree version number")
6977
print("-o <filename> Output to file")
70-
exit(1)
78+
exit(0)
7179
}
7280
}

Src/launchdXPC/launchdXPC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int getSubmittedPid(int pid) {
3131
long long lo = (temp >> 0) & 0x00000000FFFFFFFFLL;
3232
ProcessSerialNumber parentPSN = {(unsigned long)hi, (unsigned long)lo};
3333

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

Src/main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Foundation
1010

11-
let version = 0.7
11+
let version = 0.8
1212

1313
// Go through command line arguments and set accordingly
1414
let argManager = ArgManager(suppliedArgs:CommandLine.arguments)
@@ -43,14 +43,14 @@ if argManager.standardMode {
4343
parentNode?.add(child: proc.node)
4444
}
4545
rootNode?.printTree()
46-
exit(1)
46+
exit(0)
4747
}
4848

4949

5050
// If timeline mode is active
5151
if argManager.timelineMode == false {
5252
pc.printTimeline(outputFile: argManager.toFile)
53-
exit(1)
53+
exit(0)
5454
}
5555

5656
// Create a TrueTree

Src/node.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ final class Node {
1818
let displayString: String
1919
private(set) var children: [Node]
2020

21+
var fileName: String {
22+
if let fileName = path.components(separatedBy: "/").last {
23+
return fileName
24+
}
25+
26+
return path
27+
}
28+
2129
init(_ pid: Int, path: String, timestamp: String, source: String, displayString: String) {
2230
self.pid = pid
2331
self.path = path
@@ -59,7 +67,12 @@ extension Node {
5967

6068
} else {
6169
if argManager.color {
62-
text = "\(displayString) \(String(pid).magenta)"
70+
if argManager.showpath {
71+
text = "\(displayString)"
72+
} else {
73+
text = "\(fileName)"
74+
}
75+
if argManager.showpid { text += " \(String(pid).magenta)"}
6376
if argManager.timestamps { text += " \(timestamp.cyan)"}
6477
if argManager.sources { text += " Aquired parent from -> \(source)".red }
6578
} else {

Src/process.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ class ProcessCollector {
8484

8585
// Get true parent. Plist parents will be handled elsewhere
8686
let trueParent: Int
87-
if submittedPid > 1 {
87+
if ppid != 1 {
88+
trueParent = ppid
89+
source = "parent_process"
90+
} else if submittedPid > 1 {
8891
trueParent = submittedPid
8992
source = "application_services"
9093
} else if responsiblePid != pid {

TrueTree.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,13 @@
302302
CLANG_ENABLE_MODULES = YES;
303303
CLANG_USE_OPTIMIZATION_PROFILE = NO;
304304
CODE_SIGN_IDENTITY = "Apple Development";
305-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
305+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
306306
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
307307
CODE_SIGN_STYLE = Manual;
308308
DEVELOPMENT_TEAM = "";
309-
"DEVELOPMENT_TEAM[sdk=macosx*]" = C793NB2B2B;
309+
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
310310
ENABLE_HARDENED_RUNTIME = YES;
311-
INSTALL_PATH = "";
311+
INSTALL_PATH = /usr/local/bin/;
312312
MACOSX_DEPLOYMENT_TARGET = 10.13;
313313
"OTHER_CODE_SIGN_FLAGS[sdk=*]" = "--timestamp";
314314
PRODUCT_BUNDLE_IDENTIFIER = truetree;
@@ -328,13 +328,13 @@
328328
CLANG_ENABLE_MODULES = YES;
329329
CLANG_USE_OPTIMIZATION_PROFILE = NO;
330330
CODE_SIGN_IDENTITY = "Apple Development";
331-
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
331+
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
332332
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
333333
CODE_SIGN_STYLE = Manual;
334334
DEVELOPMENT_TEAM = "";
335-
"DEVELOPMENT_TEAM[sdk=macosx*]" = C793NB2B2B;
335+
"DEVELOPMENT_TEAM[sdk=macosx*]" = "";
336336
ENABLE_HARDENED_RUNTIME = YES;
337-
INSTALL_PATH = "";
337+
INSTALL_PATH = /usr/local/bin/;
338338
MACOSX_DEPLOYMENT_TARGET = 10.13;
339339
ONLY_ACTIVE_ARCH = NO;
340340
PRODUCT_BUNDLE_IDENTIFIER = truetree;

0 commit comments

Comments
 (0)