Commit c9690e02 authored by Niels Möller's avatar Niels Möller
Browse files

Added some trace calls.

Rev: src/unix_process.c:1.4
parent 0c0b49c7
...@@ -106,6 +106,9 @@ static struct lsh_process * ...@@ -106,6 +106,9 @@ static struct lsh_process *
make_unix_process(pid_t pid, int signal) make_unix_process(pid_t pid, int signal)
{ {
NEW(unix_process, self); NEW(unix_process, self);
trace("unix_process.c: make_unix_process\n");
init_resource(&self->super.super, do_kill_process); init_resource(&self->super.super, do_kill_process);
self->super.signal = do_signal_process; self->super.signal = do_signal_process;
...@@ -130,6 +133,8 @@ do_logout_notice(struct exit_callback *s, ...@@ -130,6 +133,8 @@ do_logout_notice(struct exit_callback *s,
{ {
CAST(logout_notice, self, s); CAST(logout_notice, self, s);
trace("unix_process: do_logout_notice\n");
/* No need to signal the process. */ /* No need to signal the process. */
self->process->alive = 0; self->process->alive = 0;
...@@ -165,6 +170,8 @@ do_utmp_cleanup(struct exit_callback *s, ...@@ -165,6 +170,8 @@ do_utmp_cleanup(struct exit_callback *s,
{ {
CAST(utmp_cleanup, self, s); CAST(utmp_cleanup, self, s);
trace("unix_process: do_utmp_cleanup\n");
#if HAVE_UTMP_H #if HAVE_UTMP_H
self->utmp.ut_type = DEAD_PROCESS; self->utmp.ut_type = DEAD_PROCESS;
...@@ -174,7 +181,7 @@ do_utmp_cleanup(struct exit_callback *s, ...@@ -174,7 +181,7 @@ do_utmp_cleanup(struct exit_callback *s,
#endif #endif
#if HAVE_PUTUTLINE #if HAVE_PUTUTLINE
if (!pututline(&self->utmp)) if (!pututline(&self->utmp))
werror("Updating utmp failed (errno = %i): %z\n", werror("Updating utmp for logout failed (errno = %i): %z\n",
errno, STRERROR(errno)); errno, STRERROR(errno));
#endif #endif
#endif /* HAVE_UTMP_H */ #endif /* HAVE_UTMP_H */
...@@ -222,14 +229,20 @@ utmp_book_keeping(struct lsh_string *name, ...@@ -222,14 +229,20 @@ utmp_book_keeping(struct lsh_string *name,
{ {
NEW(utmp_cleanup, cleanup); NEW(utmp_cleanup, cleanup);
trace("unix_process.c: utmp_book_keeping\n");
cleanup->super.exit = do_utmp_cleanup; cleanup->super.exit = do_utmp_cleanup;
cleanup->c = c; cleanup->c = c;
memset(&cleanup->utmp, 0, sizeof(cleanup->utmp)); memset(&cleanup->utmp, 0, sizeof(cleanup->utmp));
trace("unix_process.c: utmp_book_keeping, before tty\n");
/* utmp->ut_line exists even in our dummy utmp struct */ /* utmp->ut_line exists even in our dummy utmp struct */
CP_TTY(cleanup->utmp.ut_line, tty); CP_TTY(cleanup->utmp.ut_line, tty);
trace("unix_process.c: utmp_book_keeping, after tty\n");
#if HAVE_UTMP_H #if HAVE_UTMP_H
cleanup->utmp.ut_type = login ? LOGIN_PROCESS : USER_PROCESS; cleanup->utmp.ut_type = login ? LOGIN_PROCESS : USER_PROCESS;
CP(cleanup->utmp.ut_line, tty); CP(cleanup->utmp.ut_line, tty);
...@@ -242,18 +255,23 @@ utmp_book_keeping(struct lsh_string *name, ...@@ -242,18 +255,23 @@ utmp_book_keeping(struct lsh_string *name,
CP(cleanup->utmp.ut_name, name); CP(cleanup->utmp.ut_name, name);
#endif #endif
trace("unix_process.c: utmp_book_keeping, after name\n");
/* FIXME: Perform a reverse lookup. /* FIXME: Perform a reverse lookup.
* Also use ut_addr and ut_addr_v6 */ * Also use ut_addr and ut_addr_v6 */
#if HAVE_STRUCT_UTMP_UT_HOST #if HAVE_STRUCT_UTMP_UT_HOST
CP(cleanup->utmp.ut_host, peer->ip); CP(cleanup->utmp.ut_host, peer->ip);
#endif #endif
trace("unix_process.c: utmp_book_keeping, after host\n");
#if HAVE_PUTUTLINE #if HAVE_PUTUTLINE
if (!pututline(&cleanup->utmp)) if (!pututline(&cleanup->utmp))
werror("pututline failed (errno = %i): %z\n", werror("Updating utmp for login failed (errno = %i): %z\n",
errno, STRERROR(errno)); errno, STRERROR(errno));
#endif #endif
trace("unix_process.c: utmp_book_keeping, after pututline\n");
#endif /* HAVE_UTMP_H */ #endif /* HAVE_UTMP_H */
#if HAVE_LOGWTMP #if HAVE_LOGWTMP
...@@ -262,6 +280,8 @@ utmp_book_keeping(struct lsh_string *name, ...@@ -262,6 +280,8 @@ utmp_book_keeping(struct lsh_string *name,
lsh_get_cstring(peer->ip)); lsh_get_cstring(peer->ip));
#endif /* HAVE_LOGWTMP */ #endif /* HAVE_LOGWTMP */
trace("unix_process.c: utmp_book_keeping, after logwtmp\n");
return &cleanup->super; return &cleanup->super;
} }
#endif /* WITH_UTMP */ #endif /* WITH_UTMP */
...@@ -275,11 +295,15 @@ unix_process_setup(pid_t pid, int login, ...@@ -275,11 +295,15 @@ unix_process_setup(pid_t pid, int login,
{ {
struct lsh_process *process = make_unix_process(pid, SIGHUP); struct lsh_process *process = make_unix_process(pid, SIGHUP);
trace("unix_process.c: unix_process_setup\n");
#if WITH_UTMP #if WITH_UTMP
if (tty) if (tty)
*c = utmp_book_keeping(user->name, pid, login, peer, tty, *c); *c = utmp_book_keeping(user->name, pid, login, peer, tty, *c);
#endif #endif
trace("unix_process.c: unix_process_setup, after utmp\n");
*c = make_logout_notice(&process->super, *c); *c = make_logout_notice(&process->super, *c);
return process; return process;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment