Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mount devtmpfs filesystem for NodeOS & updated documentation
  • Loading branch information
piranna committed Mar 1, 2016
1 parent 7243ea5 commit e606934
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 11 additions & 7 deletions README.md
Expand Up @@ -7,18 +7,22 @@ system when there's no more running ones. It was initially based on

## Why?

NodeOS is an operating system build entirely on Node.js, also it's `PID 1` init
[century](https://github.com/NodeOS/node-century). Problem is, since v0.11.15
the version of v8 was changed from v3.26.33 to v3.28.73, and a bug was inserted
that forbid to use it as `PID 1` anymore. Due to this, we need to use a more
"traditional" C-based init executable.
NodeOS is an operating system build entirely on Node.js, and also it was its
`PID 1` init process ([century](https://github.com/NodeOS/node-century)).
Problem is, on v0.11.15 Node.js upgraded the version of v8 from v3.26.33 to
v3.28.73, and a regression was introducced that don't allow to use it as `PID 1`
anymore, seems related to the need of having a `devtmpfs` filesystem mounted on
`/dev` and not only defined a `/dev/console` device file. Due to this, we need
to mount it previously to any instance of Node.js can be executed, but also we
can this way control better the processes termination and cleanly shutdown the
system instead of get a *Kernel panic*.

## How?

There are 3 signals that sinit will act on.
There are 3 signals that NodeOS-init will act on.

* *SIGCHLD*: reap children
* *SIGINT*: reboots the machine (or alternatively via ctrl-alt-del)
* *SIGINT*: reboots the machine (or alternatively via `ctrl-alt-del`)
* *SIGTERM*: send the `SIGTERM` to all its child processes and later shutdown

It also shutdown the machine when it detect there are no more child processes.
6 changes: 6 additions & 0 deletions init.c
Expand Up @@ -2,6 +2,7 @@

#include <linux/reboot.h>

#include <sys/mount.h>
#include <sys/reboot.h>
#include <sys/types.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -148,6 +149,11 @@ int main(int argc, char* argv[])
// Prepare signals
sigset_t set = prepareSignals();

// Mount `devtmpfs` filesystem in `/dev`. This is mandatory for Node.js on
// NodeOS, but it's fairly common so it doesn't hurts (too much...)
if(mount("devtmpfs", "/dev", "devtmpfs", 0, NULL) == -1)
perror("mount");

// Exec init command
spawn(getCommand(argc, argv));

Expand Down

0 comments on commit e606934

Please sign in to comment.