libbb: code shrink by factoring out common update_utmp_DEAD_PROCESS

function                                             old     new   delta
update_utmp_DEAD_PROCESS                               -      17     +17
telnetd_main                                        1685    1674     -11
mark_terminated                                       56      45     -11
handle_sigchld                                        74      63     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2015-01-05 15:37:58 +01:00
parent 08b90a9d10
commit da9212667c
5 changed files with 20 additions and 16 deletions

View File

@@ -130,3 +130,17 @@ void FAST_FUNC update_utmp(pid_t pid, int new_type, const char *tty_name, const
updwtmp(bb_path_wtmp_file, &utent);
#endif
}
/* man utmp:
* When init(8) finds that a process has exited, it locates its utmp entry
* by ut_pid, sets ut_type to DEAD_PROCESS, and clears ut_user, ut_host
* and ut_time with null bytes.
* [same applies to other processes which maintain utmp entries, like telnetd]
*
* We do not bother actually clearing fields:
* it might be interesting to know who was logged in and from where
*/
void FAST_FUNC update_utmp_DEAD_PROCESS(pid_t pid)
{
update_utmp(pid, DEAD_PROCESS, NULL, NULL, NULL);
}