Method: Dir.chroot

Defined in:
dir.c

.chroot(dirpath) ⇒ 0

Changes the root directory of the calling process to that specified in dirpath. The new root directory is used for pathnames beginning with '/'. The root directory is inherited by all children of the calling process.

Only a privileged process may call chroot.

See Linux chroot.

Returns:

  • (0)

1571
1572
1573
1574
1575
1576
1577
1578
1579
# File 'dir.c', line 1571

static VALUE
dir_s_chroot(VALUE dir, VALUE path)
{
    path = check_dirname(path);
    if (IO_WITHOUT_GVL_INT(nogvl_chroot, (void *)RSTRING_PTR(path)) == -1)
        rb_sys_fail_path(path);

    return INT2FIX(0);
}