|
|
< Previous PageNext Page > |
From the perspective of a user, contexts are generally unimportant as long as they do not want a program to survive past the end of their login session.
Contexts do become a problem for the administrator, however.
For example, if the administrator upgrades sshd
by
killing the old version, starting the new one, and logging out,
strange things could happen since the context in which sshd
was
running no longer exists.
Contexts also pose an issue for users running background jobs
with nohup
or users detaching terminal sessions
using screen
. There are times when it is perfectly
reasonable for a program to survive past logout, but by default,
this does not occur.
There are three basic ways that a user can get around this. In the case of daemons, they can modify the startup scripts to start the application. On restart, the application will be started in the startup context. This is not very practical if the computer in question is in heavy use, however. Fortunately, there are other ways to start services in a startup context.
The second way to run a service in the startup context is
to use ssh
to connect to the computer. Since sshd
is
running in the startup context, programs started from an ssh
session
also register themselves in the startup context. (Note that a user
can safely kill the main sshd
process without
being logged out. The user just needs to be careful to kill the right
one.)
The third way is to log in as the console user (>console
),
which causes LoginWindow
to exit and causes init
to
spawn a getty
process on the console. Since init
spawns getty
,
which spawns login
, which spawns the user’s
shell, any programs started from the text console will be in the
startup context.
More generally, any process that is the child of a process
in the startup context (other than those inherited by init
because
their parent process exited) is automatically in the startup context.
Any process that is the child of a process in the login context
is, itself, in the login context. This means that daemons can safely
fork children at any time and those children will be in the startup
context, as will programs started from the console (not the Console application).
This also means that any program started by a user in a terminal
window, from Finder, from the Dock, and so on, will be in the currently
logged in user’s login context, even if that user runs the application
using su
or sudo
.
< Previous PageNext Page > |
Last updated: 2006-11-07
|
Get information on Apple products.
Visit the Apple Store online or at retail locations. 1-800-MY-APPLE Copyright © 2007 Apple Inc. All rights reserved. | Terms of use | Privacy Notice |