Skip to contentSkip to conversation

ss: add -P/--process-age option to display process runtime

PATCH Superseded Harshith Hari 2 participants 2 messages Sep 15 – Sep 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ss: add -P/--process-age option to display process runtime

Add a new option (-P/--process-age) to display process uptime/age alongside process info inside socket user context output.

---
v2:
- Fixed patch whitespace and tab formatting.

---
 man/man8/ss.8 |   3 +
 misc/ss.c     | 662 +++++++++++++++++++++++++++++---------------------
 2 files changed, 385 insertions(+), 280 deletions(-)
man/man8/ss.8 +3 -0
index b0629b82..5f345c21 100644
@@ -163,6 +163,9 @@ the number of packets dropped before they are de-multiplexed into the socket
 .TP
 \.B \-P, \-\-process\-age
 Show process age/runtime alongside process socket information.
+.TP
+\.B \-P, \-\-process\-age
+Show process age/runtime alongside process socket information.
 Show processes using sockets.
 .TP
 .B \-T, \-\-threads
misc/ss.c +382 -280

1,176 lines not on this page · raw message

Signature · 1 line
2.43.7
#1 lore raw
Quoted 23 lines · On Wed, 16 Sep 2026 03:01:00 +0530 Harshith Hari…
misc/ss.c +0 -15
index 6c32455d..6058ca29 100644
@@ -56,58 +56,58 @@ static int show_process_age;
 
 static void print_process_age(pid_t pid)
 {
-char path[64];
-FILE *f;
-unsigned long long starttime;
-double uptime = 0.0;
-long clock_ticks = sysconf(_SC_CLK_TCK);
-
-f = fopen("/proc/uptime", "r");
-if (!f)
-return;
-
-if (fscanf(f, "%lf", &uptime) != 1) {
-fclose(f);
-return;
-}
-fclose(f);

misc/ss.c static int show_process_age; · line 68

Quoted 10 lines
misc/ss.c +9 -0
+	char path[64];
+	FILE *f;
+	unsigned long long starttime;
+	double uptime = 0.0;
+	long clock_ticks = sysconf(_SC_CLK_TCK);
+
+	f = fopen("/proc/uptime", "r");
+	if (!f)
+		return;
 

You are not starting with existing upstream source! There is no code with /proc/uptime in upstream version of misc/ss.c

Also the point of ss is to print info about sockets, not to be a replacement for ps.