Re: running at boot time & signals



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

maria wrote:
> I need to automatically run a program everytime my computer boots up.
> Right now, I'm doing that by linking it from /etc/rc1.d. The problem
> is that, since it's running as part of init, it doesn't receive
> signals. I need it to receive a SIGINT when I hit ctrl-c, and this
> isn't happening.

Of course not. /Those/ processes run by init at startup don't have a
controlling terminal, and thus can't receive any SIGINT generated by you.

> Is there any way I can get this to work, either by
> running the program in some other way outside of init, or by
> configuring it to receive signals through init?

If you want the programs to run at start up (as opposed to when a
particular user logs on), you have to run then through the init inittab
processing. Such processes are not assigned a controlling terminal by
default, although you can override this by an explicit redirect of stdin
and stdout to the desired terminal. (Note, this is independant of a user
logon at that terminal; anyone who can get to the terminal will be in
control of your process).

OTOH, if you want the process to run when you log on, then you can
launch it from your .profile (or one of it's variants or parents). Read
the manpage for your shell (man bash, for instance) to find out which
files are executed automatically on user logon. Running your process
this way gives it a controlling terminal that you can then enter a
SIGINT from.

Having got this far, it occurs to me that you are probably trying to
solve the wrong problem. If you care to explain what your process does,
why you want to run it when you do, and why you want to SIGINT it,
perhaps we can suggest a better way to arrange things. You /probably/
don't need a controlling terminal and SIGINT to do what you want.

- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFD1ozhagVFX4UWr64RAsMyAKCju3E/jMJvHwUBpZePSKUJs2eN9wCgme02
NFqs4ceuxfaIFO0ARuQ3lho=
=+Ea5
-----END PGP SIGNATURE-----
.



Relevant Pages

  • shutdown_nice during boot
    ... initproc is initialized quite early during boot to make sure that PID of 1 is ... Actual init process is executed at the very end of boot. ... after init is forked it ignores all signals because this is how proc0 is set up. ... It's possible to re-enable SIGINT right after init is forked, ...
    (freebsd-arch)
  • Re: running at boot time & signals
    ... > want it to run once and then quit. ... FWIW, "wait" makes init wait until the process ends. ... Lew Pitcher, IT Specialist, Enterprise Data Systems ...
    (comp.os.linux.development.system)