lkml.org 
[lkml]   [2003]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: how to restart userland?
On Mon, 3 Nov 2003, Tomas Szepe wrote:

> Hi,
>
> Would anyone know of a proven way to completely restart the userland
> of a Linux system?
>
> i.e. something like
> # echo whatever-restart >/proc/wherever
>
> Killing all processes.
> Killing init.
> Unmounting all filesystems.
> VFS: Mounted root (ext2 filesystem).
> INIT: v2.84 booting
> ...
>
> Thanks for any pointers,
> --
> Tomas Szepe <szepe@pinerecords.com>
> -

If you have an 'old' sys-V installation, you as root can execute
`init 0`. Then, after everything has stopped, you can execute
`init 5` or `init 6` to restart to the runlevel you had. More
modern versions from (probably all) distributions won't allow
this. But... you may be able to make a script. The problem is
in fooling init to start all over again. You really need to modify
init (perhaps runlevel 10) to, after everything is unmounted and
all the gettys are killed, do:

char *argv[3];
argv[0] ="/sbin/init";
argv[1] ="auto";
argv[2] = NULL;
execve(argv[0], argv, __environ);

That will overlay and restart init from scratch.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [from the cache]
©2003-2011 Jasper Spaans