… | |
… | |
4 | |
4 | |
5 | SYNOPSIS |
5 | SYNOPSIS |
6 | use Linux::Clone; |
6 | use Linux::Clone; |
7 | |
7 | |
8 | DESCRIPTION |
8 | DESCRIPTION |
9 | This module exposes the linux clone(2) and unshare(2) syscalls to Perl. |
9 | This module exposes the linux clone(2), unshare(2) and related syscalls |
|
|
10 | to Perl. |
10 | |
11 | |
11 | $retval = unshare $flags |
12 | $retval = unshare $flags |
12 | The following CLONE_ flag values (without CLONE_ prefix) are |
13 | The following CLONE_ flag values (without CLONE_ prefix) are |
13 | supported for unshare, if found, in this release. See the |
14 | supported for unshare, if found, in this release. See the |
14 | documentation for unshare(2) for more info on what they do: |
15 | documentation for unshare(2) for more info on what they do: |
… | |
… | |
18 | Linux::Clone::NEWNS (in unshare, implies FS) |
19 | Linux::Clone::NEWNS (in unshare, implies FS) |
19 | Linux::Clone::VM (in unshare, implies SIGHAND) |
20 | Linux::Clone::VM (in unshare, implies SIGHAND) |
20 | Linux::Clone::THREAD (in unshare, implies VM, SIGHAND) |
21 | Linux::Clone::THREAD (in unshare, implies VM, SIGHAND) |
21 | Linux::Clone::SIGHAND |
22 | Linux::Clone::SIGHAND |
22 | Linux::Clone::SYSVSEM |
23 | Linux::Clone::SYSVSEM |
|
|
24 | Linux::Clone::NEWUSER (in unshare, implies CLONE_THREAD) |
|
|
25 | Linux::Clone::NEWPID |
23 | Linux::Clone::NEWUTS |
26 | Linux::Clone::NEWUTS |
24 | Linux::Clone::NEWIPC |
27 | Linux::Clone::NEWIPC |
25 | Linux::Clone::NEWNET |
28 | Linux::Clone::NEWNET |
|
|
29 | Linux::Clone::NEWCGROUP |
26 | |
30 | |
27 | Example: unshare the network namespace and prove that by calling |
31 | Example: unshare the network namespace and prove that by calling |
28 | ifconfig, showing only an unconfigured lo interface. |
32 | ifconfig, showing only an unconfigured lo interface. |
29 | |
33 | |
30 | Linux::Clone::unshare Linux::Clone::NEWNET |
34 | Linux::Clone::unshare Linux::Clone::NEWNET |
… | |
… | |
118 | Linux::Clone::PARENT_SETTID (not yet implemented) |
122 | Linux::Clone::PARENT_SETTID (not yet implemented) |
119 | Linux::Clone::CHILD_SETTID (not yet implemented) |
123 | Linux::Clone::CHILD_SETTID (not yet implemented) |
120 | Linux::Clone::CHILD_CLEARTID (not yet implemented) |
124 | Linux::Clone::CHILD_CLEARTID (not yet implemented) |
121 | Linux::Clone::DETACHED |
125 | Linux::Clone::DETACHED |
122 | Linux::Clone::UNTRACED |
126 | Linux::Clone::UNTRACED |
123 | Linux::Clone::NEWUSER |
|
|
124 | Linux::Clone::NEWPID |
|
|
125 | Linux::Clone::IO |
127 | Linux::Clone::IO |
126 | |
128 | |
127 | Note that for practical reasons you basically must not use |
129 | Note that for practical reasons you basically must not use |
128 | "Linux::Clone::VM" or "Linux::Clone::VFORK", as perl is unlikely to |
130 | "Linux::Clone::VM" or "Linux::Clone::VFORK", as perl is unlikely to |
129 | cope with that. |
131 | cope with that. |
… | |
… | |
133 | Example: do a fork-like clone, sharing nothing, slightly confusing |
135 | Example: do a fork-like clone, sharing nothing, slightly confusing |
134 | perl and your libc, and exit immediately. |
136 | perl and your libc, and exit immediately. |
135 | |
137 | |
136 | my $pid = Linux::Clone::clone sub { warn "in child"; 77 }, 0, POSIX::SIGCHLD; |
138 | my $pid = Linux::Clone::clone sub { warn "in child"; 77 }, 0, POSIX::SIGCHLD; |
137 | |
139 | |
|
|
140 | Linux::Clone::setns $fh_or_fd[, $nstype] |
|
|
141 | Calls setns(2) on the file descriptor (or file handle) $fh_or_fd. If |
|
|
142 | $nstype is missing, then 0 is used. |
|
|
143 | |
|
|
144 | At the time of this writing, $nstype can be 0, |
|
|
145 | "Linux::Clone::NEWIPC", "Linux::Clone::NEWNET", |
|
|
146 | "Linux::Clone::NEUTS", "Linux::Clone::NEWCGROUP", |
|
|
147 | "Linux::Clone::NEWNS", "Linux::Clone::NEWPID" or |
|
|
148 | "Linux::Clone::NEWUSER". |
|
|
149 | |
138 | AUTHOR |
150 | AUTHOR |
139 | Marc Lehmann <schmorp@schmorp.de> |
151 | Marc Lehmann <schmorp@schmorp.de> |
140 | http://home.schmorp.de/ |
152 | http://home.schmorp.de/ |
141 | |
153 | |