[PATCH] set DEAD_PROCESS for died proccess with pid in utmp table

Petr Lautrbach plautrba at redhat.com
Thu Jan 6 10:08:43 UTC 2011


On 01/06/2011 08:38 AM, Scott James Remnant wrote:
> Could you explain the 3rd patch a bit more for me, how do you see the
> utmp entries working throughout the lifecycle - what would both
> Upstart and mingetty do?
>

It's focused on respawning processes.

There is no utmp entry when mingetty is run first time and mingetty sets it itself
to LOGIN_PROCESS.
After mingetty's end this entry is set in job_process_terminated() to DEAD_PROCES
and the job->utmp_id is set to value found in utmp table.
For respawning jobs this value stays in job structure for next job_process_run().
It is used there for setting up UPSTART_UTMP_ID job environment variable which is used in
job_process_spawn() to change DEAD_PROCESS utmp entry to INIT_PROCESS and pid of new process.
So mingetty can find it and change it to LOGIN_PROCESS.

Petr


> On Wed, Jan 5, 2011 at 3:36 PM, Petr Lautrbach<plautrba at redhat.com>  wrote:
>> On 06/15/2010 04:39 PM, Petr Lautrbach wrote:
>>>
>>> Hello,
>>>
>>> Attached patch tries to fix #183729.
>>>
>>> If we assume that *getty takes care about setting
>>> INIT_PROCESS/LOGIN_PROCESS itself, we need
>>> just set DEAD_PROCESS for dead processes with pid in utmp table and log it
>>> into wtmp.
>>>
>>> Init goes through the utmp table, tries to find entry with dead process
>>> pid and sets it
>>> to DEAD_PROCESS. There is no need to create/set up "utmp" stanza.
>>>
>>> Test covers utmp table with 2 entries and with 2 situation - process is in
>>> LOGIN_PROCESS or USER_PROCESS.
>>>
>>
>> Hello.
>>
>> Sorry for very late response.
>>
>> There should not be setutxent() on job_process.c:1180. If there are more
>> than one record in utmp table then
>> it causes that only first entry will be overwritten every time. Attached
>> patch [1] adds test which covers this situation and
>> [2] removes this call.
>>
>> But this is not still ideal. It seems that mingetty doesn't use DEAD_PROCESS
>> entry if it's not last entry in table.
>> So if there are some sequence of login/logout on various consoles utmp will
>> grow. It's fixed by patch [3].
>> When utmp entry for dead process is found then job->utmp_id is set. When new
>> process is spawned and job->utmp_id is set
>> then INIT_PROCESS utmp entry for its id is created. This works well for
>> respawning processes.
>>
>> [1] 0001-test-multiple-entries-with-same-ut_id.patch
>> [2] 0002-remove-setutxent-when-setting-DEAD_PROCESS.patch
>> [3] 0003-set-INIT_PROCESS-entry.patch
>>
>> Petr
>> --
>> Petr Lautrbach, Red Hat, Inc.
>>
>> --
>> upstart-devel mailing list
>> upstart-devel at lists.ubuntu.com
>> Modify settings or unsubscribe at:
>> https://lists.ubuntu.com/mailman/listinfo/upstart-devel
>>
>>
>


-- 
Petr Lautrbach, Red Hat, Inc.



More information about the upstart-devel mailing list