--- kill.c Sat Aug 4 15:11:31 2001 +++ kill.c.new Fri Oct 25 04:53:40 2002 @@ -143,6 +143,7 @@ */ /* copy the session structure to our address space */ +#if __FreeBSD_version <= 500023 if (kvm_read(kd, (unsigned long)processes[0].kp_eproc.e_tsess, &tty_session, sizeof(tty_session)) != sizeof(tty_session)) { syslog(LOG_ERR, "kvm_read failed (%s:%d): %s", __FILE__, __LINE__, kvm_geterr(kd)); goto failure; @@ -162,7 +163,36 @@ /* success? well possibly..we don't actually check the process went */ return_value = 1; } +#else /* if __FreeBSD_version >= 500023 */ + if (kvm_read(kd, (unsigned long) processes[0].ki_paddr->p_session, &tty_session, + sizeof(tty_session)) != sizeof(tty_session)) { + syslog(LOG_ERR, "kvm_read failed (%s:%d): %s", + __FILE__, __LINE__, kvm_geterr(kd)); + goto failure; + } + + /* copy the session leader's structp proc to our address space */ + if (processes[0].ki_kiflag & KI_SLEADER) { + if (kvm_read(kd, (unsigned long)tty_session.s_leader, + &session_leader, sizeof(session_leader)) != + sizeof(session_leader)) { + syslog(LOG_ERR, "kvm_read failed (%s:%d): %s", + __FILE__, __LINE__, kvm_geterr(kd)); + goto failure; + } + /* send a hangup signal to the shell */ + if (kill(session_leader.p_pid, SIGHUP) != 0) { + syslog(LOG_ERR, "kill failed (%s:%d): %m", __FILE__, + __LINE__); + goto failure; + } else { + /* success? well possibly.. we don't know actually + * check where the process went */ + return_value = 1; + } + } +#endif /* we skip to here if things fail so we always close the kvm interface. * we could have used massive if staements or do/while(0) and break but * we didn't */