diff --git a/bashrc.sh b/bashrc.sh index 7e51e3b..e1d0854 100644 --- a/bashrc.sh +++ b/bashrc.sh @@ -2,6 +2,7 @@ PATH=$PATH:~/.resh/bin export __RESH_RT_SESSION=$EPOCHREALTIME export __RESH_RT_SESS_SINCE_BOOT=$(cat /proc/uptime | cut -d' ' -f1) +export __RESH_SESSION_ID=$RANDOM nohup resh-daemon &>/dev/null & disown preexec() { @@ -24,7 +25,7 @@ preexec() { # non-posix __RESH_PID="$BASHPID" # current pid - __RESH_SESSION_PID="$$" # pid of original shell + __RESH_SHELL_PID="$$" # pid but subshells don't affect it __RESH_WINDOWID="$WINDOWID" # session __RESH_HOST="$HOSTNAME" __RESH_HOSTTYPE="$HOSTTYPE" @@ -54,7 +55,7 @@ precmd() { -pwd "$__RESH_PWD" \ -shell "$__RESH_SHELL" \ -term "$__RESH_TERM" \ - -pid "$__RESH_PID" -sessionPid "$__RESH_SESSION_PID" \ + -pid "$__RESH_PID" -shellPid "$__RESH_SHELL_PID" \ -windowId "$__RESH_WINDOWID" \ -host "$__RESH_HOST" \ -hosttype "$__RESH_HOSTTYPE" \ diff --git a/collect/resh-collect.go b/collect/resh-collect.go index a905d0c..edbfb10 100644 --- a/collect/resh-collect.go +++ b/collect/resh-collect.go @@ -45,7 +45,8 @@ func main() { // non-posix pid := flag.Int("pid", -1, "$PID") - sessionPid := flag.Int("sessionPid", -1, "$$") + shellPid := flag.Int("shellPid", -1, + "$$ (pid but subshells don't affect it)") windowId := flag.Int("windowId", -1, "$WINDOWID - session id") shlvl := flag.Int("shlvl", -1, "$SHLVL") @@ -104,14 +105,14 @@ func main() { Term: *term, // non-posix - Pid: *pid, - SessionPid: *sessionPid, - WindowId: *windowId, - Host: *host, - Hosttype: *hosttype, - Ostype: *ostype, - Machtype: *machtype, - Shlvl: *shlvl, + Pid: *pid, + ShellPid: *shellPid, + WindowId: *windowId, + Host: *host, + Hosttype: *hosttype, + Ostype: *ostype, + Machtype: *machtype, + Shlvl: *shlvl, // before after TimezoneBefore: *timezoneBefore, @@ -127,7 +128,7 @@ func main() { RealtimeSinceBoot: realtimeSinceBoot, GitWorkTree: getGitDir(), - MachineId: getMachineId(), + MachineId: getMachineId(), } sendRecord(rec, strconv.Itoa(config.Port)) } diff --git a/common/resh-common.go b/common/resh-common.go index 6221008..f1d87e1 100644 --- a/common/resh-common.go +++ b/common/resh-common.go @@ -19,7 +19,7 @@ type Record struct { // non-posix"` Pid int `json:"pid"` - SessionPid int `json:"sessionPid"` + ShellPid int `json:"shellPid"` WindowId int `json:"windowId"` Host string `json:"host"` Hosttype string `json:"hosttype"`