- pid_t ppid;
- if (*pathbuf == '\0') {
- if ((tty = ttynr()) == -1)
- errx(1, "failed to get tty number");
- ppid = getppid();
- if (snprintf(pathbuf, sizeof pathbuf, "%s/.%d_%d",
- TIMESTAMP_DIR, tty, ppid) == -1)
- return -1;
- }
- *path = pathbuf;
- return 0;
+ pid_t ppid, sid;
+ if ((tty = ttynr()) == -1)
+ errx(1, "failed to get tty number");
+ ppid = getppid();
+ if ((sid = getsid(0)) == -1)
+ err(1, "getsid");
+ if (snprintf(pathbuf, sizeof pathbuf, "%s/.%d_%d_%d",
+ TIMESTAMP_DIR, tty, ppid, sid) == -1)
+ return NULL;
+ return pathbuf;