1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2013-03-26 16:48+0900\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <LL@li.org>\n"
16 "Content-Type: text/plain; charset=CHARSET\n"
17 "Content-Transfer-Encoding: 8bit\n"
20 #: build/C/man3/CPU_SET.3:27
26 #: build/C/man3/CPU_SET.3:27
32 #: build/C/man3/CPU_SET.3:27 build/C/man2/clone.2:45 build/C/man2/kcmp.2:28 build/C/man2/sched_get_priority_max.2:29 build/C/man3/sched_getcpu.3:26 build/C/man2/sched_rr_get_interval.2:29 build/C/man2/sched_setaffinity.2:34 build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:46 build/C/man2/sched_yield.2:29 build/C/man2/setns.2:8 build/C/man2/unshare.2:20
38 #: build/C/man3/CPU_SET.3:27 build/C/man2/clone.2:45 build/C/man2/kcmp.2:28 build/C/man2/sched_get_priority_max.2:29 build/C/man3/sched_getcpu.3:26 build/C/man2/sched_rr_get_interval.2:29 build/C/man2/sched_setaffinity.2:34 build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:46 build/C/man2/sched_yield.2:29 build/C/man2/setns.2:8 build/C/man2/unshare.2:20
40 msgid "Linux Programmer's Manual"
44 #: build/C/man3/CPU_SET.3:28 build/C/man2/clone.2:46 build/C/man2/kcmp.2:29 build/C/man2/sched_get_priority_max.2:30 build/C/man3/sched_getcpu.3:27 build/C/man2/sched_rr_get_interval.2:30 build/C/man2/sched_setaffinity.2:35 build/C/man2/sched_setparam.2:31 build/C/man2/sched_setscheduler.2:47 build/C/man2/sched_yield.2:30 build/C/man2/setns.2:9 build/C/man2/unshare.2:21
50 #: build/C/man3/CPU_SET.3:35
52 "CPU_SET, CPU_CLR, CPU_ISSET, CPU_ZERO, CPU_COUNT, CPU_AND, CPU_OR, CPU_XOR, "
53 "CPU_EQUAL, CPU_ALLOC, CPU_ALLOC_SIZE, CPU_FREE, CPU_SET_S, CPU_CLR_S, "
54 "CPU_ISSET_S, CPU_ZERO_S, CPU_COUNT_S, CPU_AND_S, CPU_OR_S, CPU_XOR_S, "
55 "CPU_EQUAL_S - macros for manipulating CPU sets"
59 #: build/C/man3/CPU_SET.3:35 build/C/man2/clone.2:48 build/C/man2/kcmp.2:31 build/C/man2/sched_get_priority_max.2:32 build/C/man3/sched_getcpu.3:29 build/C/man2/sched_rr_get_interval.2:32 build/C/man2/sched_setaffinity.2:38 build/C/man2/sched_setparam.2:33 build/C/man2/sched_setscheduler.2:50 build/C/man2/sched_yield.2:32 build/C/man2/setns.2:11 build/C/man2/unshare.2:23
64 #. Actually _BSD_SOURCE || _SVID_SOURCE
65 #. FIXME See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
67 #: build/C/man3/CPU_SET.3:39 build/C/man2/clone.2:54 build/C/man2/sched_setaffinity.2:42 build/C/man2/setns.2:15 build/C/man2/unshare.2:29
70 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
71 "B<#include E<lt>sched.hE<gt>>\n"
75 #: build/C/man3/CPU_SET.3:41
77 msgid "B<void CPU_ZERO(cpu_set_t *>I<set>B<);>\n"
81 #: build/C/man3/CPU_SET.3:45
84 "B<void CPU_SET(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
85 "B<void CPU_CLR(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
86 "B<int CPU_ISSET(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
90 #: build/C/man3/CPU_SET.3:47
92 msgid "B<int CPU_COUNT(cpu_set_t *>I<set>B<);>\n"
96 #: build/C/man3/CPU_SET.3:54
99 "B<void CPU_AND(cpu_set_t *>I<destset>B<,>\n"
100 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
101 "B<void CPU_OR(cpu_set_t *>I<destset>B<,>\n"
102 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
103 "B<void CPU_XOR(cpu_set_t *>I<destset>B<,>\n"
104 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
108 #: build/C/man3/CPU_SET.3:56
110 msgid "B<int CPU_EQUAL(cpu_set_t *>I<set1>B<, cpu_set_t *>I<set2>B<);>\n"
114 #: build/C/man3/CPU_SET.3:60
117 "B<cpu_set_t *CPU_ALLOC(int >I<num_cpus>B<);>\n"
118 "B<void CPU_FREE(cpu_set_t *>I<set>B<);>\n"
119 "B<size_t CPU_ALLOC_SIZE(int >I<num_cpus>B<);>\n"
123 #: build/C/man3/CPU_SET.3:62
125 msgid "B<void CPU_ZERO_S(size_t >I<setsize>B<, cpu_set_t *>I<set>B<);>\n"
129 #: build/C/man3/CPU_SET.3:66
132 "B<void CPU_SET_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
134 "B<void CPU_CLR_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
136 "B<int CPU_ISSET_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
141 #: build/C/man3/CPU_SET.3:68
143 msgid "B<int CPU_COUNT_S(size_t >I<setsize>B<, cpu_set_t *>I<set>B<);>\n"
147 #: build/C/man3/CPU_SET.3:75
150 "B<void CPU_AND_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
151 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
152 "B<void CPU_OR_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
153 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
154 "B<void CPU_XOR_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
155 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
159 #: build/C/man3/CPU_SET.3:78
162 "B<int CPU_EQUAL_S(size_t >I<setsize>B<, cpu_set_t *>I<set1>B<, cpu_set_t "
167 #: build/C/man3/CPU_SET.3:79 build/C/man2/clone.2:60 build/C/man2/kcmp.2:41 build/C/man2/sched_get_priority_max.2:38 build/C/man3/sched_getcpu.3:37 build/C/man2/sched_rr_get_interval.2:36 build/C/man2/sched_setaffinity.2:49 build/C/man2/sched_setparam.2:47 build/C/man2/sched_setscheduler.2:66 build/C/man2/sched_yield.2:36 build/C/man2/setns.2:18 build/C/man2/unshare.2:32
173 #: build/C/man3/CPU_SET.3:86
175 "The I<cpu_set_t> data structure represents a set of CPUs. CPU sets are used "
176 "by B<sched_setaffinity>(2) and similar interfaces."
180 #: build/C/man3/CPU_SET.3:93
182 "The I<cpu_set_t> data type is implemented as a bitset. However, the data "
183 "structure treated as considered opaque: all manipulation of CPU sets should "
184 "be done via the macros described in this page."
188 #: build/C/man3/CPU_SET.3:96
189 msgid "The following macros are provided to operate on the CPU set I<set>:"
193 #: build/C/man3/CPU_SET.3:96
195 msgid "B<CPU_ZERO>()"
199 #: build/C/man3/CPU_SET.3:101
200 msgid "Clears I<set>, so that it contains no CPUs."
204 #: build/C/man3/CPU_SET.3:101
210 #: build/C/man3/CPU_SET.3:107
211 msgid "Add CPU I<cpu> to I<set>."
215 #: build/C/man3/CPU_SET.3:107
221 #: build/C/man3/CPU_SET.3:113
222 msgid "Remove CPU I<cpu> from I<set>."
226 #: build/C/man3/CPU_SET.3:113
228 msgid "B<CPU_ISSET>()"
232 #: build/C/man3/CPU_SET.3:119
233 msgid "Test to see if CPU I<cpu> is a member of I<set>."
237 #: build/C/man3/CPU_SET.3:119
239 msgid "B<CPU_COUNT>()"
243 #: build/C/man3/CPU_SET.3:123
244 msgid "Return the number of CPUs in I<set>."
248 #: build/C/man3/CPU_SET.3:128
250 "Where a I<cpu> argument is specified, it should not produce side effects, "
251 "since the above macros may evaluate the argument more than once."
255 #: build/C/man3/CPU_SET.3:139
257 "The first available CPU on the system corresponds to a I<cpu> value of 0, "
258 "the next CPU corresponds to a I<cpu> value of 1, and so on. The constant "
259 "B<CPU_SETSIZE> (currently 1024) specifies a value one greater than the "
260 "maximum CPU number that can be stored in I<cpu_set_t>."
264 #: build/C/man3/CPU_SET.3:141
265 msgid "The following macros perform logical operations on CPU sets:"
269 #: build/C/man3/CPU_SET.3:141
275 #: build/C/man3/CPU_SET.3:150
277 "Store the intersection of the sets I<srcset1> and I<srcset2> in I<destset> "
278 "(which may be one of the source sets)."
282 #: build/C/man3/CPU_SET.3:150
288 #: build/C/man3/CPU_SET.3:159
290 "Store the union of the sets I<srcset1> and I<srcset2> in I<destset> (which "
291 "may be one of the source sets)."
295 #: build/C/man3/CPU_SET.3:159
301 #: build/C/man3/CPU_SET.3:173
303 "Store the XOR of the sets I<srcset1> and I<srcset2> in I<destset> (which may "
304 "be one of the source sets). The XOR means the set of CPUs that are in "
305 "either I<srcset1> or I<srcset2>, but not both."
309 #: build/C/man3/CPU_SET.3:173
311 msgid "B<CPU_EQUAL>()"
315 #: build/C/man3/CPU_SET.3:176
316 msgid "Test whether two CPU set contain exactly the same CPUs."
320 #: build/C/man3/CPU_SET.3:176
322 msgid "Dynamically sized CPU sets"
326 #: build/C/man3/CPU_SET.3:182
328 "Because some applications may require the ability to dynamically size CPU "
329 "sets (e.g., to allocate sets larger than that defined by the standard "
330 "I<cpu_set_t> data type), glibc nowadays provides a set of macros to support "
335 #: build/C/man3/CPU_SET.3:184
336 msgid "The following macros are used to allocate and deallocate CPU sets:"
340 #: build/C/man3/CPU_SET.3:184
342 msgid "B<CPU_ALLOC>()"
346 #: build/C/man3/CPU_SET.3:189
348 "Allocate a CPU set large enough to hold CPUs in the range 0 to "
353 #: build/C/man3/CPU_SET.3:189
355 msgid "B<CPU_ALLOC_SIZE>()"
359 #: build/C/man3/CPU_SET.3:199
361 "Return the size in bytes of the CPU set that would be needed to hold CPUs in "
362 "the range 0 to I<num_cpus-1>. This macro provides the value that can be "
363 "used for the I<setsize> argument in the B<CPU_*_S>() macros described "
368 #: build/C/man3/CPU_SET.3:199
370 msgid "B<CPU_FREE>()"
374 #: build/C/man3/CPU_SET.3:203
375 msgid "Free a CPU set previously allocated by B<CPU_ALLOC>()."
379 #: build/C/man3/CPU_SET.3:210
381 "The macros whose names end with \"_S\" are the analogs of the similarly "
382 "named macros without the suffix. These macros perform the same tasks as "
383 "their analogs, but operate on the dynamically allocated CPU set(s) whose "
384 "size is I<setsize> bytes."
388 #: build/C/man3/CPU_SET.3:210 build/C/man2/clone.2:806 build/C/man2/kcmp.2:124 build/C/man2/sched_get_priority_max.2:86 build/C/man3/sched_getcpu.3:40 build/C/man2/sched_rr_get_interval.2:73 build/C/man2/sched_setaffinity.2:107 build/C/man2/sched_setparam.2:87 build/C/man2/sched_setscheduler.2:422 build/C/man2/sched_yield.2:41 build/C/man2/setns.2:70 build/C/man2/unshare.2:189
394 #: build/C/man3/CPU_SET.3:219
396 "B<CPU_ISSET>() and B<CPU_ISSET_S>() return nonzero if I<cpu> is in I<set>; "
397 "otherwise, it returns 0."
401 #: build/C/man3/CPU_SET.3:225
402 msgid "B<CPU_COUNT>() and B<CPU_COUNT_S>() return the number of CPUs in I<set>."
406 #: build/C/man3/CPU_SET.3:230
408 "B<CPU_EQUAL>() and B<CPU_EQUAL_S>() return nonzero if the two CPU sets are "
409 "equal; otherwise it returns 0."
413 #: build/C/man3/CPU_SET.3:235
415 "B<CPU_ALLOC>() returns a pointer on success, or NULL on failure. (Errors "
416 "are as for B<malloc>(3).)"
420 #: build/C/man3/CPU_SET.3:239
422 "B<CPU_ALLOC_SIZE>() returns the number of bytes required to store a CPU set "
423 "of the specified cardinality."
427 #: build/C/man3/CPU_SET.3:241
428 msgid "The other functions do not return a value."
432 #: build/C/man3/CPU_SET.3:241 build/C/man2/clone.2:923 build/C/man2/kcmp.2:195 build/C/man3/sched_getcpu.3:52 build/C/man2/sched_setaffinity.2:148 build/C/man2/setns.2:97 build/C/man2/unshare.2:206
438 #: build/C/man3/CPU_SET.3:249
440 "The B<CPU_ZERO>(), B<CPU_SET>(), B<CPU_CLR>(), and B<CPU_ISSET>() macros "
441 "were added in glibc 2.3.3."
445 #: build/C/man3/CPU_SET.3:252
446 msgid "B<CPU_COUNT>() first appeared in glibc 2.6."
450 #: build/C/man3/CPU_SET.3:270
452 "B<CPU_AND>(), B<CPU_OR>(), B<CPU_XOR>(), B<CPU_EQUAL>(), B<CPU_ALLOC>(), "
453 "B<CPU_ALLOC_SIZE>(), B<CPU_FREE>(), B<CPU_ZERO_S>(), B<CPU_SET_S>(), "
454 "B<CPU_CLR_S>(), B<CPU_ISSET_S>(), B<CPU_AND_S>(), B<CPU_OR_S>(), "
455 "B<CPU_XOR_S>(), and B<CPU_EQUAL_S>() first appeared in glibc 2.7."
459 #: build/C/man3/CPU_SET.3:270 build/C/man2/clone.2:930 build/C/man2/kcmp.2:199 build/C/man2/sched_get_priority_max.2:100 build/C/man3/sched_getcpu.3:54 build/C/man2/sched_rr_get_interval.2:94 build/C/man2/sched_setaffinity.2:159 build/C/man2/sched_setparam.2:110 build/C/man2/sched_setscheduler.2:444 build/C/man2/sched_yield.2:52 build/C/man2/setns.2:102 build/C/man2/unshare.2:210
461 msgid "CONFORMING TO"
465 #: build/C/man3/CPU_SET.3:272
466 msgid "These interfaces are Linux-specific."
470 #: build/C/man3/CPU_SET.3:272 build/C/man2/clone.2:937 build/C/man2/kcmp.2:202 build/C/man3/sched_getcpu.3:57 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setaffinity.2:161 build/C/man2/sched_setparam.2:112 build/C/man2/sched_setscheduler.2:447 build/C/man2/sched_yield.2:54 build/C/man2/setns.2:106 build/C/man2/unshare.2:214
476 #: build/C/man3/CPU_SET.3:275
477 msgid "To duplicate a CPU set, use B<memcpy>(3)."
481 #: build/C/man3/CPU_SET.3:282
483 "Since CPU sets are bitsets allocated in units of long words, the actual "
484 "number of CPUs in a dynamically allocated CPU set will be rounded up to the "
485 "next multiple of I<sizeof(unsigned long)>. An application should consider "
486 "the contents of these extra bits to be undefined."
490 #: build/C/man3/CPU_SET.3:294
492 "Notwithstanding the similarity in the names, note that the constant "
493 "B<CPU_SETSIZE> indicates the number of CPUs in the I<cpu_set_t> data type "
494 "(thus, it is effectively a count of bits in the bitset), while the "
495 "I<setsize> argument of the B<CPU_*_S>() macros is a size in bytes."
499 #: build/C/man3/CPU_SET.3:300
501 "The data types for arguments and return values shown in the SYNOPSIS are "
502 "hints what about is expected in each case. However, since these interfaces "
503 "are implemented as macros, the compiler won't necessarily catch all type "
504 "errors if you violate the suggestions."
508 #: build/C/man3/CPU_SET.3:300 build/C/man2/clone.2:984 build/C/man2/sched_setscheduler.2:530
513 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7029
515 #: build/C/man3/CPU_SET.3:312
517 "On 32-bit platforms with glibc 2.8 and earlier, B<CPU_ALLOC>() allocates "
518 "twice as much space as is required, and B<CPU_ALLOC_SIZE>() returns a value "
519 "twice as large as it should. This bug should not affect the semantics of a "
520 "program, but does result in wasted memory and less efficient operation of "
521 "the macros that operate on dynamically allocated CPU sets. These bugs are "
522 "fixed in glibc 2.9."
526 #: build/C/man3/CPU_SET.3:312 build/C/man2/clone.2:1026 build/C/man2/setns.2:112
532 #: build/C/man3/CPU_SET.3:315
534 "The following program demonstrates the use of some of the macros used for "
535 "dynamically allocated CPU sets."
539 #: build/C/man3/CPU_SET.3:323
542 "#define _GNU_SOURCE\n"
543 "#include E<lt>sched.hE<gt>\n"
544 "#include E<lt>stdlib.hE<gt>\n"
545 "#include E<lt>unistd.hE<gt>\n"
546 "#include E<lt>stdio.hE<gt>\n"
547 "#include E<lt>assert.hE<gt>\n"
551 #: build/C/man3/CPU_SET.3:330
555 "main(int argc, char *argv[])\n"
557 " cpu_set_t *cpusetp;\n"
559 " int num_cpus, cpu;\n"
563 #: build/C/man3/CPU_SET.3:335
566 " if (argc E<lt> 2) {\n"
567 " fprintf(stderr, \"Usage: %s E<lt>num-cpusE<gt>\\en\", argv[0]);\n"
568 " exit(EXIT_FAILURE);\n"
573 #: build/C/man3/CPU_SET.3:337
575 msgid " num_cpus = atoi(argv[1]);\n"
579 #: build/C/man3/CPU_SET.3:343
582 " cpusetp = CPU_ALLOC(num_cpus);\n"
583 " if (cpusetp == NULL) {\n"
584 " perror(\"CPU_ALLOC\");\n"
585 " exit(EXIT_FAILURE);\n"
590 #: build/C/man3/CPU_SET.3:345
592 msgid " size = CPU_ALLOC_SIZE(num_cpus);\n"
596 #: build/C/man3/CPU_SET.3:349
599 " CPU_ZERO_S(size, cpusetp);\n"
600 " for (cpu = 0; cpu E<lt> num_cpus; cpu += 2)\n"
601 " CPU_SET_S(cpu, size, cpusetp);\n"
605 #: build/C/man3/CPU_SET.3:351
607 msgid " printf(\"CPU_COUNT() of set: %d\\en\", CPU_COUNT_S(size, cpusetp));\n"
611 #: build/C/man3/CPU_SET.3:355
614 " CPU_FREE(cpusetp);\n"
615 " exit(EXIT_SUCCESS);\n"
620 #: build/C/man3/CPU_SET.3:356 build/C/man2/clone.2:1124 build/C/man2/kcmp.2:219 build/C/man2/sched_get_priority_max.2:102 build/C/man3/sched_getcpu.3:77 build/C/man2/sched_rr_get_interval.2:125 build/C/man2/sched_setaffinity.2:214 build/C/man2/sched_setparam.2:118 build/C/man2/sched_setscheduler.2:538 build/C/man2/sched_yield.2:78 build/C/man2/setns.2:199 build/C/man2/unshare.2:248
626 #: build/C/man3/CPU_SET.3:361
628 "B<sched_setaffinity>(2), B<pthread_attr_setaffinity_np>(3), "
629 "B<pthread_setaffinity_np>(3), B<cpuset>(7)"
633 #: build/C/man3/CPU_SET.3:361 build/C/man2/clone.2:1138 build/C/man2/kcmp.2:222 build/C/man2/sched_get_priority_max.2:114 build/C/man3/sched_getcpu.3:79 build/C/man2/sched_rr_get_interval.2:131 build/C/man2/sched_setaffinity.2:233 build/C/man2/sched_setparam.2:134 build/C/man2/sched_setscheduler.2:567 build/C/man2/sched_yield.2:84 build/C/man2/setns.2:205 build/C/man2/unshare.2:257
639 #: build/C/man3/CPU_SET.3:368 build/C/man2/clone.2:1145 build/C/man2/kcmp.2:229 build/C/man2/sched_get_priority_max.2:121 build/C/man3/sched_getcpu.3:86 build/C/man2/sched_rr_get_interval.2:138 build/C/man2/sched_setaffinity.2:240 build/C/man2/sched_setparam.2:141 build/C/man2/sched_setscheduler.2:574 build/C/man2/sched_yield.2:91 build/C/man2/setns.2:212 build/C/man2/unshare.2:264
641 "This page is part of release 3.50 of the Linux I<man-pages> project. A "
642 "description of the project, and information about reporting bugs, can be "
643 "found at http://www.kernel.org/doc/man-pages/."
647 #: build/C/man2/clone.2:45
653 #: build/C/man2/clone.2:45 build/C/man2/setns.2:8
659 #: build/C/man2/clone.2:48
660 msgid "clone, __clone2 - create a child process"
664 #: build/C/man2/clone.2:59
667 "B<int clone(int (*>I<fn>B<)(void *), void *>I<child_stack>B<,>\n"
668 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
669 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
670 "*>I<ctid>B< */ );>\n"
674 #: build/C/man2/clone.2:71
676 "B<clone>() creates a new process, in a manner similar to B<fork>(2). It is "
677 "actually a library function layered on top of the underlying B<clone>() "
678 "system call, hereinafter referred to as B<sys_clone>. A description of "
679 "B<sys_clone> is given toward the end of this page."
683 #: build/C/man2/clone.2:83
685 "Unlike B<fork>(2), these calls allow the child process to share parts of its "
686 "execution context with the calling process, such as the memory space, the "
687 "table of file descriptors, and the table of signal handlers. (Note that on "
688 "this manual page, \"calling process\" normally corresponds to \"parent "
689 "process\". But see the description of B<CLONE_PARENT> below.)"
693 #: build/C/man2/clone.2:88
695 "The main use of B<clone>() is to implement threads: multiple threads of "
696 "control in a program that run concurrently in a shared memory space."
700 #: build/C/man2/clone.2:108
702 "When the child process is created with B<clone>(), it executes the function "
703 "I<fn>(I<arg>). (This differs from B<fork>(2), where execution continues in "
704 "the child from the point of the B<fork>(2) call.) The I<fn> argument is a "
705 "pointer to a function that is called by the child process at the beginning "
706 "of its execution. The I<arg> argument is passed to the I<fn> function."
710 #: build/C/man2/clone.2:118
712 "When the I<fn>(I<arg>) function application returns, the child process "
713 "terminates. The integer returned by I<fn> is the exit code for the child "
714 "process. The child process may also terminate explicitly by calling "
715 "B<exit>(2) or after receiving a fatal signal."
719 #: build/C/man2/clone.2:134
721 "The I<child_stack> argument specifies the location of the stack used by the "
722 "child process. Since the child and calling process may share memory, it is "
723 "not possible for the child process to execute in the same stack as the "
724 "calling process. The calling process must therefore set up memory space for "
725 "the child stack and pass a pointer to this space to B<clone>(). Stacks grow "
726 "downward on all processors that run Linux (except the HP PA processors), so "
727 "I<child_stack> usually points to the topmost address of the memory space set "
728 "up for the child stack."
732 #: build/C/man2/clone.2:150
734 "The low byte of I<flags> contains the number of the I<termination signal> "
735 "sent to the parent when the child dies. If this signal is specified as "
736 "anything other than B<SIGCHLD>, then the parent process must specify the "
737 "B<__WALL> or B<__WCLONE> options when waiting for the child with "
738 "B<wait>(2). If no signal is specified, then the parent process is not "
739 "signaled when the child terminates."
743 #: build/C/man2/clone.2:155
745 "I<flags> may also be bitwise-or'ed with zero or more of the following "
746 "constants, in order to specify what is shared between the calling process "
747 "and the child process:"
751 #: build/C/man2/clone.2:155
753 msgid "B<CLONE_CHILD_CLEARTID> (since Linux 2.5.49)"
757 #: build/C/man2/clone.2:165
759 "Erase child thread ID at location I<ctid> in child memory when the child "
760 "exits, and do a wakeup on the futex at that address. The address involved "
761 "may be changed by the B<set_tid_address>(2) system call. This is used by "
762 "threading libraries."
766 #: build/C/man2/clone.2:165
768 msgid "B<CLONE_CHILD_SETTID> (since Linux 2.5.49)"
772 #: build/C/man2/clone.2:170
773 msgid "Store child thread ID at location I<ctid> in child memory."
777 #: build/C/man2/clone.2:170
779 msgid "B<CLONE_FILES> (since Linux 2.0)"
783 #: build/C/man2/clone.2:183
785 "If B<CLONE_FILES> is set, the calling process and the child process share "
786 "the same file descriptor table. Any file descriptor created by the calling "
787 "process or by the child process is also valid in the other process. "
788 "Similarly, if one of the processes closes a file descriptor, or changes its "
789 "associated flags (using the B<fcntl>(2) B<F_SETFD> operation), the other "
790 "process is also affected."
794 #: build/C/man2/clone.2:197
796 "If B<CLONE_FILES> is not set, the child process inherits a copy of all file "
797 "descriptors opened in the calling process at the time of B<clone>(). (The "
798 "duplicated file descriptors in the child refer to the same open file "
799 "descriptions (see B<open>(2)) as the corresponding file descriptors in the "
800 "calling process.) Subsequent operations that open or close file "
801 "descriptors, or change file descriptor flags, performed by either the "
802 "calling process or the child process do not affect the other process."
806 #: build/C/man2/clone.2:197
808 msgid "B<CLONE_FS> (since Linux 2.0)"
812 #: build/C/man2/clone.2:212
814 "If B<CLONE_FS> is set, the caller and the child process share the same file "
815 "system information. This includes the root of the file system, the current "
816 "working directory, and the umask. Any call to B<chroot>(2), B<chdir>(2), or "
817 "B<umask>(2) performed by the calling process or the child process also "
818 "affects the other process."
822 #: build/C/man2/clone.2:224
824 "If B<CLONE_FS> is not set, the child process works on a copy of the file "
825 "system information of the calling process at the time of the B<clone>() "
826 "call. Calls to B<chroot>(2), B<chdir>(2), B<umask>(2) performed later by "
827 "one of the processes do not affect the other process."
831 #: build/C/man2/clone.2:224
833 msgid "B<CLONE_IO> (since Linux 2.6.25)"
837 #: build/C/man2/clone.2:233
839 "If B<CLONE_IO> is set, then the new process shares an I/O context with the "
840 "calling process. If this flag is not set, then (as with B<fork>(2)) the "
841 "new process has its own I/O context."
844 #. The following based on text from Jens Axboe
845 #. the anticipatory and CFQ scheduler
848 #: build/C/man2/clone.2:250
850 "The I/O context is the I/O scope of the disk scheduler (i.e, what the I/O "
851 "scheduler uses to model scheduling of a process's I/O). If processes share "
852 "the same I/O context, they are treated as one by the I/O scheduler. As a "
853 "consequence, they get to share disk time. For some I/O schedulers, if two "
854 "processes share an I/O context, they will be allowed to interleave their "
855 "disk access. If several threads are doing I/O on behalf of the same process "
856 "(B<aio_read>(3), for instance), they should employ B<CLONE_IO> to get better "
861 #: build/C/man2/clone.2:254
863 "If the kernel is not configured with the B<CONFIG_BLOCK> option, this flag "
868 #: build/C/man2/clone.2:254 build/C/man2/unshare.2:78
870 msgid "B<CLONE_NEWIPC> (since Linux 2.6.19)"
874 #: build/C/man2/clone.2:264
876 "If B<CLONE_NEWIPC> is set, then create the process in a new IPC namespace. "
877 "If this flag is not set, then (as with B<fork>(2)), the process is created "
878 "in the same IPC namespace as the calling process. This flag is intended for "
879 "the implementation of containers."
882 #. commit 7eafd7c74c3f2e67c27621b987b28397110d643f
883 #. https://lwn.net/Articles/312232/
885 #: build/C/man2/clone.2:276
887 "An IPC namespace provides an isolated view of System V IPC objects (see "
888 "B<svipc>(7)) and (since Linux 2.6.30) POSIX message queues (see "
889 "B<mq_overview>(7)). The common characteristic of these IPC mechanisms is "
890 "that IPC objects are identified by mechanisms other than filesystem "
895 #: build/C/man2/clone.2:280
897 "Objects created in an IPC namespace are visible to all other processes that "
898 "are members of that namespace, but are not visible to processes in other IPC "
903 #: build/C/man2/clone.2:284
905 "When an IPC namespace is destroyed (i.e., when the last process that is a "
906 "member of the namespace terminates), all IPC objects in the namespace are "
907 "automatically destroyed."
911 #: build/C/man2/clone.2:293
913 "Use of this flag requires: a kernel configured with the B<CONFIG_SYSVIPC> "
914 "and B<CONFIG_IPC_NS> options and that the process be privileged "
915 "(B<CAP_SYS_ADMIN>). This flag can't be specified in conjunction with "
920 #: build/C/man2/clone.2:293 build/C/man2/unshare.2:95
922 msgid "B<CLONE_NEWNET> (since Linux 2.6.24)"
925 #. FIXME Check when the implementation was completed
927 #: build/C/man2/clone.2:298
929 "(The implementation of this flag was only completed by about kernel version "
934 #: build/C/man2/clone.2:307
936 "If B<CLONE_NEWNET> is set, then create the process in a new network "
937 "namespace. If this flag is not set, then (as with B<fork>(2)), the process "
938 "is created in the same network namespace as the calling process. This flag "
939 "is intended for the implementation of containers."
942 #. FIXME Add pointer to veth(4) page when it is eventually completed
944 #: build/C/man2/clone.2:322
946 "A network namespace provides an isolated view of the networking stack "
947 "(network device interfaces, IPv4 and IPv6 protocol stacks, IP routing "
948 "tables, firewall rules, the I</proc/net> and I</sys/class/net> directory "
949 "trees, sockets, etc.). A physical network device can live in exactly one "
950 "network namespace. A virtual network device (\"veth\") pair provides a "
951 "pipe-like abstraction that can be used to create tunnels between network "
952 "namespaces, and can be used to create a bridge to a physical network device "
953 "in another namespace."
957 #: build/C/man2/clone.2:327
959 "When a network namespace is freed (i.e., when the last process in the "
960 "namespace terminates), its physical network devices are moved back to the "
961 "initial network namespace (not to the parent of the process)."
965 #: build/C/man2/clone.2:332
967 "Use of this flag requires: a kernel configured with the B<CONFIG_NET_NS> "
968 "option and that the process be privileged (B<CAP_SYS_ADMIN>)."
972 #: build/C/man2/clone.2:332
974 msgid "B<CLONE_NEWNS> (since Linux 2.4.19)"
978 #: build/C/man2/clone.2:335
979 msgid "Start the child in a new mount namespace."
983 #: build/C/man2/clone.2:356
985 "Every process lives in a mount namespace. The I<namespace> of a process is "
986 "the data (the set of mounts) describing the file hierarchy as seen by that "
987 "process. After a B<fork>(2) or B<clone>() where the B<CLONE_NEWNS> flag "
988 "is not set, the child lives in the same mount namespace as the parent. The "
989 "system calls B<mount>(2) and B<umount>(2) change the mount namespace of "
990 "the calling process, and hence affect all processes that live in the same "
991 "namespace, but do not affect processes in a different mount namespace."
995 #: build/C/man2/clone.2:363
997 "After a B<clone>() where the B<CLONE_NEWNS> flag is set, the cloned child "
998 "is started in a new mount namespace, initialized with a copy of the "
999 "namespace of the parent."
1003 #: build/C/man2/clone.2:375
1005 "Only a privileged process (one having the B<CAP_SYS_ADMIN> capability) may "
1006 "specify the B<CLONE_NEWNS> flag. It is not permitted to specify both "
1007 "B<CLONE_NEWNS> and B<CLONE_FS> in the same B<clone>() call."
1011 #: build/C/man2/clone.2:375
1013 msgid "B<CLONE_NEWPID> (since Linux 2.6.24)"
1016 #. This explanation draws a lot of details from
1017 #. http://lwn.net/Articles/259217/
1018 #. Authors: Pavel Emelyanov <xemul@openvz.org>
1019 #. and Kir Kolyshkin <kir@openvz.org>
1021 #. The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
1022 #. Author: Pavel Emelyanov <xemul@openvz.org>
1024 #: build/C/man2/clone.2:392
1026 "If B<CLONE_NEWPID> is set, then create the process in a new PID namespace. "
1027 "If this flag is not set, then (as with B<fork>(2)), the process is created "
1028 "in the same PID namespace as the calling process. This flag is intended for "
1029 "the implementation of containers."
1033 #: build/C/man2/clone.2:401
1035 "A PID namespace provides an isolated environment for PIDs: PIDs in a new "
1036 "namespace start at 1, somewhat like a standalone system, and calls to "
1037 "B<fork>(2), B<vfork>(2), or B<clone>() will produce processes with PIDs "
1038 "that are unique within the namespace."
1042 #: build/C/man2/clone.2:413
1044 "The first process created in a new namespace (i.e., the process created "
1045 "using the B<CLONE_NEWPID> flag) has the PID 1, and is the \"init\" process "
1046 "for the namespace. Children that are orphaned within the namespace will be "
1047 "reparented to this process rather than B<init>(8). Unlike the traditional "
1048 "B<init> process, the \"init\" process of a PID namespace can terminate, and "
1049 "if it does, all of the processes in the namespace are terminated."
1053 #: build/C/man2/clone.2:432
1055 "PID namespaces form a hierarchy. When a new PID namespace is created, the "
1056 "processes in that namespace are visible in the PID namespace of the process "
1057 "that created the new namespace; analogously, if the parent PID namespace is "
1058 "itself the child of another PID namespace, then processes in the child and "
1059 "parent PID namespaces will both be visible in the grandparent PID "
1060 "namespace. Conversely, the processes in the \"child\" PID namespace do not "
1061 "see the processes in the parent namespace. The existence of a namespace "
1062 "hierarchy means that each process may now have multiple PIDs: one for each "
1063 "namespace in which it is visible; each of these PIDs is unique within the "
1064 "corresponding namespace. (A call to B<getpid>(2) always returns the PID "
1065 "associated with the namespace in which the process lives.)"
1068 #. mount -t proc proc /proc
1070 #: build/C/man2/clone.2:448
1072 "After creating the new namespace, it is useful for the child to change its "
1073 "root directory and mount a new procfs instance at I</proc> so that tools "
1074 "such as B<ps>(1) work correctly. (If B<CLONE_NEWNS> is also included in "
1075 "I<flags>, then it isn't necessary to change the root directory: a new procfs "
1076 "instance can be mounted directly over I</proc>.)"
1080 #: build/C/man2/clone.2:455
1082 "Use of this flag requires: a kernel configured with the B<CONFIG_PID_NS> "
1083 "option and that the process be privileged (B<CAP_SYS_ADMIN>). This flag "
1084 "can't be specified in conjunction with B<CLONE_THREAD>."
1088 #: build/C/man2/clone.2:455 build/C/man2/unshare.2:131
1090 msgid "B<CLONE_NEWUTS> (since Linux 2.6.19)"
1094 #: build/C/man2/clone.2:467
1096 "If B<CLONE_NEWUTS> is set, then create the process in a new UTS namespace, "
1097 "whose identifiers are initialized by duplicating the identifiers from the "
1098 "UTS namespace of the calling process. If this flag is not set, then (as "
1099 "with B<fork>(2)), the process is created in the same UTS namespace as the "
1100 "calling process. This flag is intended for the implementation of "
1105 #: build/C/man2/clone.2:479
1107 "A UTS namespace is the set of identifiers returned by B<uname>(2); among "
1108 "these, the domain name and the host name can be modified by "
1109 "B<setdomainname>(2) and B<sethostname>(2), respectively. Changes made to "
1110 "the identifiers in a UTS namespace are visible to all other processes in the "
1111 "same namespace, but are not visible to processes in other UTS namespaces."
1115 #: build/C/man2/clone.2:484
1117 "Use of this flag requires: a kernel configured with the B<CONFIG_UTS_NS> "
1118 "option and that the process be privileged (B<CAP_SYS_ADMIN>)."
1122 #: build/C/man2/clone.2:484
1124 msgid "B<CLONE_PARENT> (since Linux 2.3.12)"
1128 #: build/C/man2/clone.2:491
1130 "If B<CLONE_PARENT> is set, then the parent of the new child (as returned by "
1131 "B<getppid>(2)) will be the same as that of the calling process."
1135 #: build/C/man2/clone.2:497
1137 "If B<CLONE_PARENT> is not set, then (as with B<fork>(2)) the child's parent "
1138 "is the calling process."
1142 #: build/C/man2/clone.2:505
1144 "Note that it is the parent process, as returned by B<getppid>(2), which is "
1145 "signaled when the child terminates, so that if B<CLONE_PARENT> is set, then "
1146 "the parent of the calling process, rather than the calling process itself, "
1151 #: build/C/man2/clone.2:505
1153 msgid "B<CLONE_PARENT_SETTID> (since Linux 2.5.49)"
1157 #: build/C/man2/clone.2:513
1159 "Store child thread ID at location I<ptid> in parent and child memory. (In "
1160 "Linux 2.5.32-2.5.48 there was a flag B<CLONE_SETTID> that did this.)"
1164 #: build/C/man2/clone.2:513
1166 msgid "B<CLONE_PID> (obsolete)"
1170 #: build/C/man2/clone.2:524
1172 "If B<CLONE_PID> is set, the child process is created with the same process "
1173 "ID as the calling process. This is good for hacking the system, but "
1174 "otherwise of not much use. Since 2.3.21 this flag can be specified only by "
1175 "the system boot process (PID 0). It disappeared in Linux 2.5.16."
1179 #: build/C/man2/clone.2:524
1181 msgid "B<CLONE_PTRACE> (since Linux 2.2)"
1185 #: build/C/man2/clone.2:531
1187 "If B<CLONE_PTRACE> is specified, and the calling process is being traced, "
1188 "then trace the child also (see B<ptrace>(2))."
1192 #: build/C/man2/clone.2:531
1194 msgid "B<CLONE_SETTLS> (since Linux 2.5.32)"
1198 #: build/C/man2/clone.2:538
1200 "The I<newtls> argument is the new TLS (Thread Local Storage) descriptor. "
1201 "(See B<set_thread_area>(2).)"
1205 #: build/C/man2/clone.2:538
1207 msgid "B<CLONE_SIGHAND> (since Linux 2.0)"
1211 #: build/C/man2/clone.2:554
1213 "If B<CLONE_SIGHAND> is set, the calling process and the child process share "
1214 "the same table of signal handlers. If the calling process or child process "
1215 "calls B<sigaction>(2) to change the behavior associated with a signal, the "
1216 "behavior is changed in the other process as well. However, the calling "
1217 "process and child processes still have distinct signal masks and sets of "
1218 "pending signals. So, one of them may block or unblock some signals using "
1219 "B<sigprocmask>(2) without affecting the other process."
1223 #: build/C/man2/clone.2:565
1225 "If B<CLONE_SIGHAND> is not set, the child process inherits a copy of the "
1226 "signal handlers of the calling process at the time B<clone>() is called. "
1227 "Calls to B<sigaction>(2) performed later by one of the processes have no "
1228 "effect on the other process."
1232 #: build/C/man2/clone.2:573
1234 "Since Linux 2.6.0-test6, I<flags> must also include B<CLONE_VM> if "
1235 "B<CLONE_SIGHAND> is specified"
1239 #: build/C/man2/clone.2:573
1241 msgid "B<CLONE_STOPPED> (since Linux 2.6.0-test2)"
1245 #: build/C/man2/clone.2:582
1247 "If B<CLONE_STOPPED> is set, then the child is initially stopped (as though "
1248 "it was sent a B<SIGSTOP> signal), and must be resumed by sending it a "
1249 "B<SIGCONT> signal."
1252 #. glibc 2.8 removed this defn from bits/sched.h
1254 #: build/C/man2/clone.2:590
1256 "This flag was I<deprecated> from Linux 2.6.25 onward, and was I<removed> "
1257 "altogether in Linux 2.6.38."
1261 #: build/C/man2/clone.2:590
1263 msgid "B<CLONE_SYSVSEM> (since Linux 2.5.10)"
1267 #: build/C/man2/clone.2:599
1269 "If B<CLONE_SYSVSEM> is set, then the child and the calling process share a "
1270 "single list of System V semaphore undo values (see B<semop>(2)). If this "
1271 "flag is not set, then the child has a separate undo list, which is initially "
1276 #: build/C/man2/clone.2:599
1278 msgid "B<CLONE_THREAD> (since Linux 2.4.0-test8)"
1282 #: build/C/man2/clone.2:608
1284 "If B<CLONE_THREAD> is set, the child is placed in the same thread group as "
1285 "the calling process. To make the remainder of the discussion of "
1286 "B<CLONE_THREAD> more readable, the term \"thread\" is used to refer to the "
1287 "processes within a thread group."
1291 #: build/C/man2/clone.2:616
1293 "Thread groups were a feature added in Linux 2.4 to support the POSIX threads "
1294 "notion of a set of threads that share a single PID. Internally, this shared "
1295 "PID is the so-called thread group identifier (TGID) for the thread group. "
1296 "Since Linux 2.4, calls to B<getpid>(2) return the TGID of the caller."
1300 #: build/C/man2/clone.2:625
1302 "The threads within a group can be distinguished by their (system-wide) "
1303 "unique thread IDs (TID). A new thread's TID is available as the function "
1304 "result returned to the caller of B<clone>(), and a thread can obtain its own "
1305 "TID using B<gettid>(2)."
1309 #: build/C/man2/clone.2:635
1311 "When a call is made to B<clone>() without specifying B<CLONE_THREAD>, then "
1312 "the resulting thread is placed in a new thread group whose TGID is the same "
1313 "as the thread's TID. This thread is the I<leader> of the new thread group."
1317 #: build/C/man2/clone.2:657
1319 "A new thread created with B<CLONE_THREAD> has the same parent process as the "
1320 "caller of B<clone>() (i.e., like B<CLONE_PARENT>), so that calls to "
1321 "B<getppid>(2) return the same value for all of the threads in a thread "
1322 "group. When a B<CLONE_THREAD> thread terminates, the thread that created it "
1323 "using B<clone>() is not sent a B<SIGCHLD> (or other termination) signal; "
1324 "nor can the status of such a thread be obtained using B<wait>(2). (The "
1325 "thread is said to be I<detached>.)"
1329 #: build/C/man2/clone.2:662
1331 "After all of the threads in a thread group terminate the parent process of "
1332 "the thread group is sent a B<SIGCHLD> (or other termination) signal."
1336 #: build/C/man2/clone.2:667
1338 "If any of the threads in a thread group performs an B<execve>(2), then all "
1339 "threads other than the thread group leader are terminated, and the new "
1340 "program is executed in the thread group leader."
1344 #: build/C/man2/clone.2:673
1346 "If one of the threads in a thread group creates a child using B<fork>(2), "
1347 "then any thread in the group can B<wait>(2) for that child."
1351 #: build/C/man2/clone.2:681
1353 "Since Linux 2.5.35, I<flags> must also include B<CLONE_SIGHAND> if "
1354 "B<CLONE_THREAD> is specified."
1358 #: build/C/man2/clone.2:686
1360 "Signals may be sent to a thread group as a whole (i.e., a TGID) using "
1361 "B<kill>(2), or to a specific thread (i.e., TID) using B<tgkill>(2)."
1365 #: build/C/man2/clone.2:691
1367 "Signal dispositions and actions are process-wide: if an unhandled signal is "
1368 "delivered to a thread, then it will affect (terminate, stop, continue, be "
1369 "ignored in) all members of the thread group."
1373 #: build/C/man2/clone.2:704
1375 "Each thread has its own signal mask, as set by B<sigprocmask>(2), but "
1376 "signals can be pending either: for the whole process (i.e., deliverable to "
1377 "any member of the thread group), when sent with B<kill>(2); or for an "
1378 "individual thread, when sent with B<tgkill>(2). A call to B<sigpending>(2) "
1379 "returns a signal set that is the union of the signals pending for the whole "
1380 "process and the signals that are pending for the calling thread."
1384 #: build/C/man2/clone.2:716
1386 "If B<kill>(2) is used to send a signal to a thread group, and the thread "
1387 "group has installed a handler for the signal, then the handler will be "
1388 "invoked in exactly one, arbitrarily selected member of the thread group that "
1389 "has not blocked the signal. If multiple threads in a group are waiting to "
1390 "accept the same signal using B<sigwaitinfo>(2), the kernel will arbitrarily "
1391 "select one of these threads to receive a signal sent using B<kill>(2)."
1395 #: build/C/man2/clone.2:716
1397 msgid "B<CLONE_UNTRACED> (since Linux 2.5.46)"
1401 #: build/C/man2/clone.2:723
1403 "If B<CLONE_UNTRACED> is specified, then a tracing process cannot force "
1404 "B<CLONE_PTRACE> on this child process."
1408 #: build/C/man2/clone.2:723
1410 msgid "B<CLONE_VFORK> (since Linux 2.2)"
1414 #: build/C/man2/clone.2:735
1416 "If B<CLONE_VFORK> is set, the execution of the calling process is suspended "
1417 "until the child releases its virtual memory resources via a call to "
1418 "B<execve>(2) or B<_exit>(2) (as with B<vfork>(2))."
1422 #: build/C/man2/clone.2:741
1424 "If B<CLONE_VFORK> is not set then both the calling process and the child are "
1425 "schedulable after the call, and an application should not rely on execution "
1426 "occurring in any particular order."
1430 #: build/C/man2/clone.2:741
1432 msgid "B<CLONE_VM> (since Linux 2.0)"
1436 #: build/C/man2/clone.2:754
1438 "If B<CLONE_VM> is set, the calling process and the child process run in the "
1439 "same memory space. In particular, memory writes performed by the calling "
1440 "process or by the child process are also visible in the other process. "
1441 "Moreover, any memory mapping or unmapping performed with B<mmap>(2) or "
1442 "B<munmap>(2) by the child or calling process also affects the other "
1447 #: build/C/man2/clone.2:763
1449 "If B<CLONE_VM> is not set, the child process runs in a separate copy of the "
1450 "memory space of the calling process at the time of B<clone>(). Memory "
1451 "writes or file mappings/unmappings performed by one of the processes do not "
1452 "affect the other, as with B<fork>(2)."
1456 #: build/C/man2/clone.2:763
1462 #: build/C/man2/clone.2:779
1464 "The B<sys_clone> system call corresponds more closely to B<fork>(2) in that "
1465 "execution in the child continues from the point of the call. As such, the "
1466 "I<fn> and I<arg> arguments of the B<clone>() wrapper function are omitted. "
1467 "Furthermore, the argument order changes. The raw system call interface is "
1472 #: build/C/man2/clone.2:785
1475 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
1476 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
1477 "B< struct pt_regs *>I<regs>B<);>\n"
1481 #: build/C/man2/clone.2:798
1483 "Another difference for B<sys_clone> is that the I<child_stack> argument may "
1484 "be zero, in which case copy-on-write semantics ensure that the child gets "
1485 "separate copies of stack pages when either process modifies the stack. In "
1486 "this case, for correct operation, the B<CLONE_VM> option should not be "
1491 #: build/C/man2/clone.2:798
1493 msgid "Linux 2.4 and earlier"
1497 #: build/C/man2/clone.2:806
1499 "In Linux 2.4 and earlier, B<clone>() does not take arguments I<ptid>, "
1500 "I<tls>, and I<ctid>."
1503 #. gettid(2) returns current->pid;
1504 #. getpid(2) returns current->tgid;
1506 #: build/C/man2/clone.2:815
1508 "On success, the thread ID of the child process is returned in the caller's "
1509 "thread of execution. On failure, -1 is returned in the caller's context, no "
1510 "child process will be created, and I<errno> will be set appropriately."
1514 #: build/C/man2/clone.2:815 build/C/man2/kcmp.2:167 build/C/man2/sched_get_priority_max.2:96 build/C/man3/sched_getcpu.3:47 build/C/man2/sched_rr_get_interval.2:80 build/C/man2/sched_setaffinity.2:116 build/C/man2/sched_setparam.2:96 build/C/man2/sched_setscheduler.2:432 build/C/man2/sched_yield.2:48 build/C/man2/setns.2:77 build/C/man2/unshare.2:194
1520 #: build/C/man2/clone.2:816
1526 #: build/C/man2/clone.2:819
1527 msgid "Too many processes are already running."
1531 #: build/C/man2/clone.2:819 build/C/man2/clone.2:826 build/C/man2/clone.2:841 build/C/man2/clone.2:849 build/C/man2/clone.2:857 build/C/man2/clone.2:865 build/C/man2/clone.2:871 build/C/man2/clone.2:881 build/C/man2/clone.2:889 build/C/man2/clone.2:897 build/C/man2/kcmp.2:178 build/C/man2/sched_get_priority_max.2:97 build/C/man2/sched_rr_get_interval.2:84 build/C/man2/sched_setaffinity.2:120 build/C/man2/sched_setaffinity.2:128 build/C/man2/sched_setparam.2:97 build/C/man2/sched_setscheduler.2:433 build/C/man2/setns.2:82 build/C/man2/unshare.2:195
1537 #: build/C/man2/clone.2:826
1539 "B<CLONE_SIGHAND> was specified, but B<CLONE_VM> was not. (Since Linux "
1546 #. .B CLONE_DETACHED
1550 #. (Since Linux 2.6.0-test6.)
1552 #: build/C/man2/clone.2:841
1554 "B<CLONE_THREAD> was specified, but B<CLONE_SIGHAND> was not. (Since Linux "
1559 #: build/C/man2/clone.2:849
1560 msgid "Both B<CLONE_FS> and B<CLONE_NEWNS> were specified in I<flags>."
1564 #: build/C/man2/clone.2:857
1565 msgid "Both B<CLONE_NEWIPC> and B<CLONE_SYSVSEM> were specified in I<flags>."
1569 #: build/C/man2/clone.2:865
1570 msgid "Both B<CLONE_NEWPID> and B<CLONE_THREAD> were specified in I<flags>."
1574 #: build/C/man2/clone.2:871
1575 msgid "Returned by B<clone>() when a zero value is specified for I<child_stack>."
1579 #: build/C/man2/clone.2:881
1581 "B<CLONE_NEWIPC> was specified in I<flags>, but the kernel was not configured "
1582 "with the B<CONFIG_SYSVIPC> and B<CONFIG_IPC_NS> options."
1586 #: build/C/man2/clone.2:889
1588 "B<CLONE_NEWNET> was specified in I<flags>, but the kernel was not configured "
1589 "with the B<CONFIG_NET_NS> option."
1593 #: build/C/man2/clone.2:897
1595 "B<CLONE_NEWPID> was specified in I<flags>, but the kernel was not configured "
1596 "with the B<CONFIG_PID_NS> option."
1600 #: build/C/man2/clone.2:905
1602 "B<CLONE_NEWUTS> was specified in I<flags>, but the kernel was not configured "
1603 "with the B<CONFIG_UTS> option."
1607 #: build/C/man2/clone.2:905 build/C/man2/setns.2:89 build/C/man2/unshare.2:199
1613 #: build/C/man2/clone.2:910
1615 "Cannot allocate sufficient memory to allocate a task structure for the "
1616 "child, or to copy those parts of the caller's context that need to be "
1621 #: build/C/man2/clone.2:910 build/C/man2/clone.2:919 build/C/man2/kcmp.2:182 build/C/man2/sched_setaffinity.2:135 build/C/man2/sched_setparam.2:101 build/C/man2/sched_setscheduler.2:438 build/C/man2/setns.2:92 build/C/man2/unshare.2:203
1627 #: build/C/man2/clone.2:919
1629 "B<CLONE_NEWIPC>, B<CLONE_NEWNET>, B<CLONE_NEWNS>, B<CLONE_NEWPID>, or "
1630 "B<CLONE_NEWUTS> was specified by an unprivileged process (process without "
1631 "B<CAP_SYS_ADMIN>)."
1635 #: build/C/man2/clone.2:923
1636 msgid "B<CLONE_PID> was specified by a process other than process 0."
1640 #: build/C/man2/clone.2:930
1642 "There is no entry for B<clone>() in libc5. glibc2 provides B<clone>() as "
1643 "described in this manual page."
1647 #: build/C/man2/clone.2:937
1649 "The B<clone>() and B<sys_clone> calls are Linux-specific and should not be "
1650 "used in programs intended to be portable."
1654 #: build/C/man2/clone.2:947
1656 "In the kernel 2.4.x series, B<CLONE_THREAD> generally does not make the "
1657 "parent of the new thread the same as the parent of the calling process. "
1658 "However, for kernel versions 2.4.7 to 2.4.18 the B<CLONE_THREAD> flag "
1659 "implied the B<CLONE_PARENT> flag (as in kernel 2.6)."
1663 #: build/C/man2/clone.2:957
1665 "For a while there was B<CLONE_DETACHED> (introduced in 2.5.32): parent wants "
1666 "no child-exit signal. In 2.6.2 the need to give this together with "
1667 "B<CLONE_THREAD> disappeared. This flag is still defined, but has no effect."
1671 #: build/C/man2/clone.2:962
1673 "On i386, B<clone>() should not be called through vsyscall, but directly "
1674 "through I<int $0x80>."
1678 #: build/C/man2/clone.2:964
1679 msgid "On ia64, a different system call is used:"
1683 #: build/C/man2/clone.2:971
1686 "B<int __clone2(int (*>I<fn>B<)(void *), >\n"
1687 "B< void *>I<child_stack_base>B<, size_t >I<stack_size>B<,>\n"
1688 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
1689 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
1690 "*>I<ctid>B< */ );>\n"
1694 #: build/C/man2/clone.2:984
1696 "The B<__clone2>() system call operates in the same way as B<clone>(), "
1697 "except that I<child_stack_base> points to the lowest address of the child's "
1698 "stack area, and I<stack_size> specifies the size of the stack pointed to by "
1699 "I<child_stack_base>."
1703 #: build/C/man2/clone.2:1015
1705 "Versions of the GNU C library that include the NPTL threading library "
1706 "contain a wrapper function for B<getpid>(2) that performs caching of PIDs. "
1707 "This caching relies on support in the glibc wrapper for B<clone>(), but as "
1708 "currently implemented, the cache may not be up to date in some "
1709 "circumstances. In particular, if a signal is delivered to the child "
1710 "immediately after the B<clone>() call, then a call to B<getpid>(2) in a "
1711 "handler for the signal may return the PID of the calling process (\"the "
1712 "parent\"), if the clone wrapper has not yet had a chance to update the PID "
1713 "cache in the child. (This discussion ignores the case where the child was "
1714 "created using B<CLONE_THREAD>, when B<getpid>(2) I<should> return the same "
1715 "value in the child and in the process that called B<clone>(), since the "
1716 "caller and the child are in the same thread group. The stale-cache problem "
1717 "also does not occur if the I<flags> argument includes B<CLONE_VM>.) To get "
1718 "the truth, it may be necessary to use code such as the following:"
1722 #: build/C/man2/clone.2:1018
1724 msgid " #include E<lt>syscall.hE<gt>\n"
1728 #: build/C/man2/clone.2:1020
1730 msgid " pid_t mypid;\n"
1734 #: build/C/man2/clone.2:1022
1736 msgid " mypid = syscall(SYS_getpid);\n"
1740 #: build/C/man2/clone.2:1027
1742 msgid "Create a child that executes in a separate UTS namespace"
1746 #: build/C/man2/clone.2:1037
1748 "The following program demonstrates the use of B<clone>() to create a child "
1749 "process that executes in a separate UTS namespace. The child changes the "
1750 "hostname in its UTS namespace. Both parent and child then display the "
1751 "system hostname, making it possible to see that the hostname differs in the "
1752 "UTS namespaces of the parent and child. For an example of the use of this "
1753 "program, see B<setns>(2)."
1757 #: build/C/man2/clone.2:1047
1760 "#define _GNU_SOURCE\n"
1761 "#include E<lt>sys/wait.hE<gt>\n"
1762 "#include E<lt>sys/utsname.hE<gt>\n"
1763 "#include E<lt>sched.hE<gt>\n"
1764 "#include E<lt>string.hE<gt>\n"
1765 "#include E<lt>stdio.hE<gt>\n"
1766 "#include E<lt>stdlib.hE<gt>\n"
1767 "#include E<lt>unistd.hE<gt>\n"
1771 #: build/C/man2/clone.2:1050 build/C/man2/setns.2:177
1774 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\e\n"
1779 #: build/C/man2/clone.2:1055
1782 "static int /* Start function for cloned child */\n"
1783 "childFunc(void *arg)\n"
1785 " struct utsname uts;\n"
1789 #: build/C/man2/clone.2:1057
1791 msgid " /* Change hostname in UTS namespace of child */\n"
1795 #: build/C/man2/clone.2:1060
1798 " if (sethostname(arg, strlen(arg)) == -1)\n"
1799 " errExit(\"sethostname\");\n"
1803 #: build/C/man2/clone.2:1062
1805 msgid " /* Retrieve and display hostname */\n"
1809 #: build/C/man2/clone.2:1066
1812 " if (uname(&uts) == -1)\n"
1813 " errExit(\"uname\");\n"
1814 " printf(\"uts.nodename in child: %s\\en\", uts.nodename);\n"
1818 #: build/C/man2/clone.2:1070
1821 " /* Keep the namespace open for a while, by sleeping.\n"
1822 " This allows some experimentation--for example, another\n"
1823 " process might join the namespace. */\n"
1827 #: build/C/man2/clone.2:1072
1829 msgid " sleep(200);\n"
1833 #: build/C/man2/clone.2:1075
1836 " return 0; /* Child terminates now */\n"
1841 #: build/C/man2/clone.2:1077
1843 msgid "#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */\n"
1847 #: build/C/man2/clone.2:1085
1851 "main(int argc, char *argv[])\n"
1853 " char *stack; /* Start of stack buffer */\n"
1854 " char *stackTop; /* End of stack buffer */\n"
1856 " struct utsname uts;\n"
1860 #: build/C/man2/clone.2:1090
1863 " if (argc E<lt> 2) {\n"
1864 " fprintf(stderr, \"Usage: %s E<lt>child-hostnameE<gt>\\en\", "
1866 " exit(EXIT_SUCCESS);\n"
1871 #: build/C/man2/clone.2:1092
1873 msgid " /* Allocate stack for child */\n"
1877 #: build/C/man2/clone.2:1097
1880 " stack = malloc(STACK_SIZE);\n"
1881 " if (stack == NULL)\n"
1882 " errExit(\"malloc\");\n"
1883 " stackTop = stack + STACK_SIZE; /* Assume stack grows downward */\n"
1887 #: build/C/man2/clone.2:1100
1890 " /* Create child that has its own UTS namespace;\n"
1891 " child commences execution in childFunc() */\n"
1895 #: build/C/man2/clone.2:1105
1898 " pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);\n"
1900 " errExit(\"clone\");\n"
1901 " printf(\"clone() returned %ld\\en\", (long) pid);\n"
1905 #: build/C/man2/clone.2:1107
1907 msgid " /* Parent falls through to here */\n"
1911 #: build/C/man2/clone.2:1109
1913 msgid " sleep(1); /* Give child time to change its hostname */\n"
1917 #: build/C/man2/clone.2:1112
1920 " /* Display hostname in parent\\(aqs UTS namespace. This will be\n"
1921 " different from hostname in child\\(aqs UTS namespace. */\n"
1925 #: build/C/man2/clone.2:1116
1928 " if (uname(&uts) == -1)\n"
1929 " errExit(\"uname\");\n"
1930 " printf(\"uts.nodename in parent: %s\\en\", uts.nodename);\n"
1934 #: build/C/man2/clone.2:1120
1937 " if (waitpid(pid, NULL, 0) == -1) /* Wait for child */\n"
1938 " errExit(\"waitpid\");\n"
1939 " printf(\"child has terminated\\en\");\n"
1943 #: build/C/man2/clone.2:1123
1946 " exit(EXIT_SUCCESS);\n"
1951 #: build/C/man2/clone.2:1138
1953 "B<fork>(2), B<futex>(2), B<getpid>(2), B<gettid>(2), B<kcmp>(2), "
1954 "B<set_thread_area>(2), B<set_tid_address>(2), B<setns>(2), B<tkill>(2), "
1955 "B<unshare>(2), B<wait>(2), B<capabilities>(7), B<pthreads>(7)"
1959 #: build/C/man2/kcmp.2:28
1965 #: build/C/man2/kcmp.2:28
1971 #: build/C/man2/kcmp.2:31
1972 msgid "kcmp - compare two processes to determine if they share a kernel resource"
1976 #: build/C/man2/kcmp.2:34
1978 msgid "B<#include E<lt>linux/kcmp.hE<gt>>\n"
1982 #: build/C/man2/kcmp.2:37
1985 "B<int kcmp(pid_t >I<pid1>B<, pid_t >I<pid2>B<, int >I<type>B<,>\n"
1986 "B< unsigned long >I<idx1>B<, unsigned long >I<idx2>B<);>\n"
1990 #: build/C/man2/kcmp.2:41
1991 msgid "I<Note>: There is no glibc wrapper for this system call; see NOTES."
1995 #: build/C/man2/kcmp.2:50
1997 "The B<kcmp>() system call can be used to check whether the two processes "
1998 "identified by I<pid1> and I<pid2> share a kernel resource such as virtual "
1999 "memory, file descriptors, and so on."
2003 #: build/C/man2/kcmp.2:55
2005 "The I<type> argument specifies which resource is to be compared in the two "
2006 "processes. It has one of the following values:"
2010 #: build/C/man2/kcmp.2:55
2012 msgid "B<KCMP_FILE>"
2016 #: build/C/man2/kcmp.2:67
2018 "Check whether a file descriptor I<idx1> in the process I<pid1> refers to the "
2019 "same open file description (see B<open>(2)) as file descriptor I<idx2> in "
2020 "the process I<pid2>."
2024 #: build/C/man2/kcmp.2:67
2026 msgid "B<KCMP_FILES>"
2030 #: build/C/man2/kcmp.2:75
2032 "Check whether the process share the same set of open file descriptors. The "
2033 "arguments I<idx1> and I<idx2> are ignored."
2037 #: build/C/man2/kcmp.2:75
2043 #: build/C/man2/kcmp.2:84
2045 "Check whether the processes share the same file system information (i.e., "
2046 "file mode creation mask, working directory, and file system root). The "
2047 "arguments I<idx1> and I<idx2> are ignored."
2051 #: build/C/man2/kcmp.2:84
2057 #: build/C/man2/kcmp.2:92
2059 "Check whether the processes share I/O context. The arguments I<idx1> and "
2060 "I<idx2> are ignored."
2064 #: build/C/man2/kcmp.2:92
2066 msgid "B<KCMP_SIGHAND>"
2070 #: build/C/man2/kcmp.2:100
2072 "Check whether the processes share the same table of signal dispositions. "
2073 "The arguments I<idx1> and I<idx2> are ignored."
2077 #: build/C/man2/kcmp.2:100
2079 msgid "B<KCMP_SYSVSEM>"
2083 #: build/C/man2/kcmp.2:109
2085 "Check whether the processes share the same list of System V semaphore undo "
2086 "operations. The arguments I<idx1> and I<idx2> are ignored."
2090 #: build/C/man2/kcmp.2:109
2096 #: build/C/man2/kcmp.2:117
2098 "Check whether the processes share the same address space. The arguments "
2099 "I<idx1> and I<idx2> are ignored."
2103 #: build/C/man2/kcmp.2:124
2105 "Note the B<kcmp>() is not protected against false positives which may have "
2106 "place if tasks are running. Which means one should stop tasks being "
2107 "inspected with this syscall to obtain meaningful results."
2111 #: build/C/man2/kcmp.2:130
2113 "The return value of a successful call to B<kcmp>() is simply the result of "
2114 "arithmetic comparison of kernel pointers (when the kernel compares "
2115 "resources, it uses their memory addresses)."
2119 #: build/C/man2/kcmp.2:138
2121 "The easiest way to explain is to consider an example. Suppose that I<v1> "
2122 "and I<v2> are the addresses of appropriate resources, then the return value "
2123 "is one of the following:"
2127 #: build/C/man2/kcmp.2:139
2133 #: build/C/man2/kcmp.2:144
2135 "I<v1> is equal to I<v2>; in other words, the two processes share the "
2140 #: build/C/man2/kcmp.2:144
2146 #: build/C/man2/kcmp.2:148
2147 msgid "I<v1> is less than I<v2>."
2151 #: build/C/man2/kcmp.2:148
2157 #: build/C/man2/kcmp.2:152
2158 msgid "I<v1> is greater than I<v2>."
2162 #: build/C/man2/kcmp.2:152
2168 #: build/C/man2/kcmp.2:157
2169 msgid "I<v1> is not equal to I<v2>, but ordering information is unavailable."
2173 #: build/C/man2/kcmp.2:162
2174 msgid "On error, -1 is returned, and I<errno> is set appropriately."
2178 #: build/C/man2/kcmp.2:167
2180 "B<kcmp ()> was designed to return values suitable for sorting. This is "
2181 "particularly handy if one needs to compare a large number of file "
2186 #: build/C/man2/kcmp.2:168 build/C/man2/setns.2:78
2192 #: build/C/man2/kcmp.2:178
2193 msgid "I<type> is B<KCMP_FILE> and I<fd1> or I<fd2> is not an open file descriptor."
2197 #: build/C/man2/kcmp.2:182
2198 msgid "I<type> is invalid."
2202 #: build/C/man2/kcmp.2:188
2204 "Insufficient permission to inspect process resources. The B<CAP_SYS_PTRACE> "
2205 "capability is required to inspect processes that you do not own."
2209 #: build/C/man2/kcmp.2:188 build/C/man2/sched_rr_get_interval.2:90 build/C/man2/sched_setaffinity.2:145 build/C/man2/sched_setparam.2:107 build/C/man2/sched_setscheduler.2:441
2215 #: build/C/man2/kcmp.2:195
2216 msgid "Process I<pid1> or I<pid2> does not exist."
2220 #: build/C/man2/kcmp.2:199
2221 msgid "The B<kcmp>() system call first appeared in Linux 3.5."
2225 #: build/C/man2/kcmp.2:202
2227 "B<kcmp>() is Linux specific and should not be used in programs intended to "
2232 #: build/C/man2/kcmp.2:205
2234 "Glibc does not provide a wrapper for this system call; call it using "
2239 #: build/C/man2/kcmp.2:214
2241 "This system call is available only if the kernel was configured with "
2242 "B<CONFIG_CHECKPOINT_RESTORE>. The main use of the system call is for the "
2243 "checkpoint/restore in user space (CRIU) feature. The alternative to this "
2244 "system call would have been to expose suitable process information via the "
2245 "B<proc>(5) file system; this was deemed to be unsuitable for security "
2250 #: build/C/man2/kcmp.2:219
2252 "See B<clone>(2) for some background information on the shared resources "
2253 "referred to on this page."
2257 #: build/C/man2/kcmp.2:222
2258 msgid "B<clone>(2), B<unshare>(2)"
2262 #: build/C/man2/sched_get_priority_max.2:29
2264 msgid "SCHED_GET_PRIORITY_MAX"
2268 #: build/C/man2/sched_get_priority_max.2:29
2274 #: build/C/man2/sched_get_priority_max.2:32
2275 msgid "sched_get_priority_max, sched_get_priority_min - get static priority range"
2279 #: build/C/man2/sched_get_priority_max.2:34 build/C/man2/sched_rr_get_interval.2:34 build/C/man2/sched_yield.2:34
2280 msgid "B<#include E<lt>sched.hE<gt>>"
2284 #: build/C/man2/sched_get_priority_max.2:36
2285 msgid "B<int sched_get_priority_max(int >I<policy>B<);>"
2289 #: build/C/man2/sched_get_priority_max.2:38
2290 msgid "B<int sched_get_priority_min(int >I<policy>B<);>"
2294 #: build/C/man2/sched_get_priority_max.2:54
2296 "B<sched_get_priority_max>() returns the maximum priority value that can be "
2297 "used with the scheduling algorithm identified by I<policy>. "
2298 "B<sched_get_priority_min>() returns the minimum priority value that can be "
2299 "used with the scheduling algorithm identified by I<policy>. Supported "
2300 "I<policy> values are B<SCHED_FIFO>, B<SCHED_RR>, B<SCHED_OTHER>, and "
2301 "B<SCHED_BATCH>. Further details about these policies can be found in "
2302 "B<sched_setscheduler>(2)."
2306 #: build/C/man2/sched_get_priority_max.2:63
2308 "Processes with numerically higher priority values are scheduled before "
2309 "processes with numerically lower priority values. Thus, the value returned "
2310 "by B<sched_get_priority_max>() will be greater than the value returned by "
2311 "B<sched_get_priority_min>()."
2315 #: build/C/man2/sched_get_priority_max.2:69
2317 "Linux allows the static priority value range 1 to 99 for B<SCHED_FIFO> and "
2318 "B<SCHED_RR> and the priority 0 for B<SCHED_OTHER> and B<SCHED_BATCH>. "
2319 "Scheduling priority ranges for the various policies are not alterable."
2323 #: build/C/man2/sched_get_priority_max.2:78
2325 "The range of scheduling priorities may vary on other POSIX systems, thus it "
2326 "is a good idea for portable applications to use a virtual priority range and "
2327 "map it to the interval given by B<sched_get_priority_max>() and "
2328 "B<sched_get_priority_min>(). POSIX.1-2001 requires a spread of at least 32 "
2329 "between the maximum and the minimum values for B<SCHED_FIFO> and "
2334 #: build/C/man2/sched_get_priority_max.2:86
2336 "POSIX systems on which B<sched_get_priority_max>() and "
2337 "B<sched_get_priority_min>() are available define "
2338 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2342 #: build/C/man2/sched_get_priority_max.2:96
2344 "On success, B<sched_get_priority_max>() and B<sched_get_priority_min>() "
2345 "return the maximum/minimum priority value for the named scheduling policy. "
2346 "On error, -1 is returned, and I<errno> is set appropriately."
2350 #: build/C/man2/sched_get_priority_max.2:100
2351 msgid "The argument I<policy> does not identify a defined scheduling policy."
2355 #: build/C/man2/sched_get_priority_max.2:102 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setparam.2:112 build/C/man2/sched_yield.2:54
2356 msgid "POSIX.1-2001."
2360 #: build/C/man2/sched_get_priority_max.2:111
2362 "B<sched_getaffinity>(2), B<sched_getparam>(2), B<sched_getscheduler>(2), "
2363 "B<sched_setaffinity>(2), B<sched_setparam>(2), B<sched_setscheduler>(2)"
2367 #: build/C/man2/sched_get_priority_max.2:114 build/C/man2/sched_rr_get_interval.2:131 build/C/man2/sched_setparam.2:134 build/C/man2/sched_setscheduler.2:563 build/C/man2/sched_yield.2:84
2369 "I<Programming for the real world - POSIX.4> by Bill O. Gallmeister, O'Reilly "
2370 "& Associates, Inc., ISBN 1-56592-074-0."
2374 #: build/C/man3/sched_getcpu.3:26
2376 msgid "SCHED_GETCPU"
2380 #: build/C/man3/sched_getcpu.3:26
2386 #: build/C/man3/sched_getcpu.3:29
2387 msgid "sched_getcpu - determine CPU on which the calling thread is running"
2390 #. Really:_BSD_SOURCE || _SVID_SOURCE
2392 #: build/C/man3/sched_getcpu.3:34
2395 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
2396 "B<#include E<lt>sched.hE<gt>>\n"
2400 #: build/C/man3/sched_getcpu.3:36
2402 msgid "B<int sched_getcpu(void);>\n"
2406 #: build/C/man3/sched_getcpu.3:40
2408 "B<sched_getcpu>() returns the number of the CPU on which the calling thread "
2409 "is currently executing."
2413 #: build/C/man3/sched_getcpu.3:47
2415 "On success, B<sched_getcpu>() returns a nonnegative CPU number. On error, "
2416 "-1 is returned and I<errno> is set to indicate the error."
2420 #: build/C/man3/sched_getcpu.3:48 build/C/man2/sched_rr_get_interval.2:87
2426 #: build/C/man3/sched_getcpu.3:52
2427 msgid "This kernel does not implement B<getcpu>(2)."
2431 #: build/C/man3/sched_getcpu.3:54
2432 msgid "This function is available since glibc 2.6."
2436 #: build/C/man3/sched_getcpu.3:57
2437 msgid "B<sched_getcpu>() is glibc specific."
2441 #: build/C/man3/sched_getcpu.3:59
2446 #: build/C/man3/sched_getcpu.3:63
2448 msgid "cpu = sched_getcpu();\n"
2452 #: build/C/man3/sched_getcpu.3:69
2453 msgid "is equivalent to the following B<getcpu>(2) call:"
2457 #: build/C/man3/sched_getcpu.3:75
2461 "s = getcpu(&c, NULL, NULL);\n"
2462 "cpu = (s == -1) ? s : c;\n"
2466 #: build/C/man3/sched_getcpu.3:79
2467 msgid "B<getcpu>(2)"
2471 #: build/C/man2/sched_rr_get_interval.2:29
2473 msgid "SCHED_RR_GET_INTERVAL"
2477 #: build/C/man2/sched_rr_get_interval.2:29
2483 #: build/C/man2/sched_rr_get_interval.2:32
2484 msgid "sched_rr_get_interval - get the SCHED_RR interval for the named process"
2488 #: build/C/man2/sched_rr_get_interval.2:36
2489 msgid "B<int sched_rr_get_interval(pid_t >I<pid>B<, struct timespec * >I<tp>B<);>"
2493 #: build/C/man2/sched_rr_get_interval.2:47
2495 "B<sched_rr_get_interval>() writes into the I<timespec> structure pointed to "
2496 "by I<tp> the round-robin time quantum for the process identified by I<pid>. "
2497 "The specified process should be running under the B<SCHED_RR> scheduling "
2502 #: build/C/man2/sched_rr_get_interval.2:51
2503 msgid "The I<timespec> structure has the following form:"
2507 #: build/C/man2/sched_rr_get_interval.2:58
2510 "struct timespec {\n"
2511 " time_t tv_sec; /* seconds */\n"
2512 " long tv_nsec; /* nanoseconds */\n"
2516 #. FIXME . On Linux, sched_rr_get_interval()
2517 #. returns the timeslice for SCHED_OTHER processes -- this timeslice
2518 #. is influenced by the nice value.
2519 #. For SCHED_FIFO processes, this always returns 0.
2521 #. The round-robin time quantum value is not alterable under Linux
2524 #: build/C/man2/sched_rr_get_interval.2:73
2526 "If I<pid> is zero, the time quantum for the calling process is written into "
2531 #: build/C/man2/sched_rr_get_interval.2:80
2533 "On success, B<sched_rr_get_interval>() returns 0. On error, -1 is "
2534 "returned, and I<errno> is set appropriately."
2538 #: build/C/man2/sched_rr_get_interval.2:81 build/C/man2/sched_setaffinity.2:117
2544 #: build/C/man2/sched_rr_get_interval.2:84
2545 msgid "Problem with copying information to user space."
2549 #: build/C/man2/sched_rr_get_interval.2:87
2550 msgid "Invalid pid."
2554 #: build/C/man2/sched_rr_get_interval.2:90
2555 msgid "The system call is not yet implemented (only on rather old kernels)."
2559 #: build/C/man2/sched_rr_get_interval.2:94
2560 msgid "Could not find a process with the ID I<pid>."
2564 #: build/C/man2/sched_rr_get_interval.2:103
2566 "POSIX systems on which B<sched_rr_get_interval>() is available define "
2567 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2571 #: build/C/man2/sched_rr_get_interval.2:103
2576 #. commit a4ec24b48ddef1e93f7578be53270f0b95ad666c
2578 #. As of Linux 1.3.81
2579 #. .BR sched_rr_get_interval ()
2580 #. returns with error
2581 #. ENOSYS, because SCHED_RR has not yet been fully implemented and tested
2584 #: build/C/man2/sched_rr_get_interval.2:125
2586 "POSIX does not specify any mechanism for controlling the size of the "
2587 "round-robin time quantum. Older Linux kernels provide a (nonportable) "
2588 "method of doing this. The quantum can be controlled by adjusting the "
2589 "process's nice value (see B<setpriority>(2)). Assigning a negative (i.e., "
2590 "high) nice value results in a longer quantum; assigning a positive (i.e., "
2591 "low) nice value results in a shorter quantum. The default quantum is 0.1 "
2592 "seconds; the degree to which changing the nice value affects the quantum has "
2593 "varied somewhat across kernel versions. Since Linux 2.6.24, the B<SCHED_RR> "
2594 "quantum cannot be modified."
2598 #: build/C/man2/sched_rr_get_interval.2:128 build/C/man2/sched_setaffinity.2:177
2599 msgid "B<sched_setscheduler>(2) has a description of the Linux scheduling scheme."
2603 #: build/C/man2/sched_setaffinity.2:34
2605 msgid "SCHED_SETAFFINITY"
2609 #: build/C/man2/sched_setaffinity.2:34
2615 #: build/C/man2/sched_setaffinity.2:38
2617 "sched_setaffinity, sched_getaffinity - set and get a process's CPU affinity "
2622 #: build/C/man2/sched_setaffinity.2:45
2625 "B<int sched_setaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2626 "B< cpu_set_t *>I<mask>B<);>\n"
2630 #: build/C/man2/sched_setaffinity.2:48
2633 "B<int sched_getaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2634 "B< cpu_set_t *>I<mask>B<);>\n"
2638 #: build/C/man2/sched_setaffinity.2:63
2640 "A process's CPU affinity mask determines the set of CPUs on which it is "
2641 "eligible to run. On a multiprocessor system, setting the CPU affinity mask "
2642 "can be used to obtain performance benefits. For example, by dedicating one "
2643 "CPU to a particular process (i.e., setting the affinity mask of that process "
2644 "to specify a single CPU, and setting the affinity mask of all other "
2645 "processes to exclude that CPU), it is possible to ensure maximum execution "
2646 "speed for that process. Restricting a process to run on a single CPU also "
2647 "avoids the performance cost caused by the cache invalidation that occurs "
2648 "when a process ceases to execute on one CPU and then recommences execution "
2649 "on a different CPU."
2653 #: build/C/man2/sched_setaffinity.2:70
2655 "A CPU affinity mask is represented by the I<cpu_set_t> structure, a \"CPU "
2656 "set\", pointed to by I<mask>. A set of macros for manipulating CPU sets is "
2657 "described in B<CPU_SET>(3)."
2661 #: build/C/man2/sched_setaffinity.2:85
2663 "B<sched_setaffinity>() sets the CPU affinity mask of the process whose ID "
2664 "is I<pid> to the value specified by I<mask>. If I<pid> is zero, then the "
2665 "calling process is used. The argument I<cpusetsize> is the length (in "
2666 "bytes) of the data pointed to by I<mask>. Normally this argument would be "
2667 "specified as I<sizeof(cpu_set_t)>."
2671 #: build/C/man2/sched_setaffinity.2:92
2673 "If the process specified by I<pid> is not currently running on one of the "
2674 "CPUs specified in I<mask>, then that process is migrated to one of the CPUs "
2675 "specified in I<mask>."
2679 #: build/C/man2/sched_setaffinity.2:107
2681 "B<sched_getaffinity>() writes the affinity mask of the process whose ID is "
2682 "I<pid> into the I<cpu_set_t> structure pointed to by I<mask>. The "
2683 "I<cpusetsize> argument specifies the size (in bytes) of I<mask>. If I<pid> "
2684 "is zero, then the mask of the calling process is returned."
2688 #: build/C/man2/sched_setaffinity.2:116
2690 "On success, B<sched_setaffinity>() and B<sched_getaffinity>() return 0. "
2691 "On error, -1 is returned, and I<errno> is set appropriately."
2695 #: build/C/man2/sched_setaffinity.2:120
2696 msgid "A supplied memory address was invalid."
2700 #: build/C/man2/sched_setaffinity.2:128
2702 "The affinity bit mask I<mask> contains no processors that are currently "
2703 "physically on the system and permitted to the process according to any "
2704 "restrictions that may be imposed by the \"cpuset\" mechanism described in "
2709 #: build/C/man2/sched_setaffinity.2:135
2711 "(B<sched_getaffinity>() and, in kernels before 2.6.9, "
2712 "B<sched_setaffinity>()) I<cpusetsize> is smaller than the size of the "
2713 "affinity mask used by the kernel."
2717 #: build/C/man2/sched_setaffinity.2:145
2719 "(B<sched_setaffinity>()) The calling process does not have appropriate "
2720 "privileges. The caller needs an effective user ID equal to the real user ID "
2721 "or effective user ID of the process identified by I<pid>, or it must possess "
2722 "the B<CAP_SYS_NICE> capability."
2726 #: build/C/man2/sched_setaffinity.2:148 build/C/man2/sched_setparam.2:110 build/C/man2/sched_setscheduler.2:444
2727 msgid "The process whose ID is I<pid> could not be found."
2731 #: build/C/man2/sched_setaffinity.2:159
2733 "The CPU affinity system calls were introduced in Linux kernel 2.5.8. The "
2734 "system call wrappers were introduced in glibc 2.3. Initially, the glibc "
2735 "interfaces included a I<cpusetsize> argument, typed as I<unsigned int>. In "
2736 "glibc 2.3.3, the I<cpusetsize> argument was removed, but was then restored "
2737 "in glibc 2.3.4, with type I<size_t>."
2741 #: build/C/man2/sched_setaffinity.2:161
2742 msgid "These system calls are Linux-specific."
2746 #: build/C/man2/sched_setaffinity.2:174
2748 "After a call to B<sched_setaffinity>(), the set of CPUs on which the process "
2749 "will actually run is the intersection of the set specified in the I<mask> "
2750 "argument and the set of CPUs actually present on the system. The system may "
2751 "further restrict the set of CPUs on which the process runs if the \"cpuset\" "
2752 "mechanism described in B<cpuset>(7) is being used. These restrictions on "
2753 "the actual set of CPUs on which the process will run are silently imposed by "
2758 #: build/C/man2/sched_setaffinity.2:194
2760 "The affinity mask is actually a per-thread attribute that can be adjusted "
2761 "independently for each of the threads in a thread group. The value returned "
2762 "from a call to B<gettid>(2) can be passed in the argument I<pid>. "
2763 "Specifying I<pid> as 0 will set the attribute for the calling thread, and "
2764 "passing the value returned from a call to B<getpid>(2) will set the "
2765 "attribute for the main thread of the thread group. (If you are using the "
2766 "POSIX threads API, then use B<pthread_setaffinity_np>(3) instead of "
2767 "B<sched_setaffinity>().)"
2771 #: build/C/man2/sched_setaffinity.2:200
2773 "A child created via B<fork>(2) inherits its parent's CPU affinity mask. "
2774 "The affinity mask is preserved across an B<execve>(2)."
2778 #: build/C/man2/sched_setaffinity.2:214
2780 "This manual page describes the glibc interface for the CPU affinity calls. "
2781 "The actual system call interface is slightly different, with the I<mask> "
2782 "being typed as I<unsigned long *>, reflecting the fact that the underlying "
2783 "implementation of CPU sets is a simple bit mask. On success, the raw "
2784 "B<sched_getaffinity>() system call returns the size (in bytes) of the "
2785 "I<cpumask_t> data type that is used internally by the kernel to represent "
2786 "the CPU set bit mask."
2790 #: build/C/man2/sched_setaffinity.2:233
2792 "B<taskset>(1), B<clone>(2), B<getcpu>(2), B<getpriority>(2), B<gettid>(2), "
2793 "B<nice>(2), B<sched_get_priority_max>(2), B<sched_get_priority_min>(2), "
2794 "B<sched_getscheduler>(2), B<sched_setscheduler>(2), B<setpriority>(2), "
2795 "B<CPU_SET>(3), B<pthread_setaffinity_np>(3), B<sched_getcpu>(3), "
2796 "B<capabilities>(7), B<cpuset>(7)"
2800 #: build/C/man2/sched_setparam.2:30
2802 msgid "SCHED_SETPARAM"
2806 #: build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:46
2812 #: build/C/man2/sched_setparam.2:33
2813 msgid "sched_setparam, sched_getparam - set and get scheduling parameters"
2817 #: build/C/man2/sched_setparam.2:36 build/C/man2/sched_setscheduler.2:53
2819 msgid "B<#include E<lt>sched.hE<gt>>\n"
2823 #: build/C/man2/sched_setparam.2:38
2826 "B<int sched_setparam(pid_t >I<pid>B<, const struct sched_param "
2831 #: build/C/man2/sched_setparam.2:40
2833 msgid "B<int sched_getparam(pid_t >I<pid>B<, struct sched_param *>I<param>B<);>\n"
2837 #: build/C/man2/sched_setparam.2:46 build/C/man2/sched_setscheduler.2:65
2840 "B<struct sched_param {\n"
2842 " int >I<sched_priority>B<;\n"
2848 #: build/C/man2/sched_setparam.2:60
2850 "B<sched_setparam>() sets the scheduling parameters associated with the "
2851 "scheduling policy for the process identified by I<pid>. If I<pid> is zero, "
2852 "then the parameters of the calling process are set. The interpretation of "
2853 "the argument I<param> depends on the scheduling policy of the process "
2854 "identified by I<pid>. See B<sched_setscheduler>(2) for a description of "
2855 "the scheduling policies supported under Linux."
2859 #: build/C/man2/sched_setparam.2:66
2861 "B<sched_getparam>() retrieves the scheduling parameters for the process "
2862 "identified by I<pid>. If I<pid> is zero, then the parameters of the calling "
2863 "process are retrieved."
2867 #: build/C/man2/sched_setparam.2:75
2869 "B<sched_setparam>() checks the validity of I<param> for the scheduling "
2870 "policy of the process. The value I<param-E<gt>sched_priority> must lie "
2871 "within the range given by B<sched_get_priority_min>(2) and "
2872 "B<sched_get_priority_max>(2)."
2876 #: build/C/man2/sched_setparam.2:79
2878 "For a discussion of the privileges and resource limits related to scheduling "
2879 "priority and policy, see B<sched_setscheduler>(2)."
2883 #: build/C/man2/sched_setparam.2:87
2885 "POSIX systems on which B<sched_setparam>() and B<sched_getparam>() are "
2886 "available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2890 #: build/C/man2/sched_setparam.2:96
2892 "On success, B<sched_setparam>() and B<sched_getparam>() return 0. On "
2893 "error, -1 is returned, and I<errno> is set appropriately."
2897 #: build/C/man2/sched_setparam.2:101
2898 msgid "The argument I<param> does not make sense for the current scheduling policy."
2902 #: build/C/man2/sched_setparam.2:107
2904 "The calling process does not have appropriate privileges (Linux: does not "
2905 "have the B<CAP_SYS_NICE> capability)."
2909 #: build/C/man2/sched_setparam.2:118
2911 "Scheduling parameters are in fact per-thread attributes on Linux; see "
2912 "B<sched_setscheduler>(2)."
2916 #: build/C/man2/sched_setparam.2:131
2918 "B<getpriority>(2), B<nice>(2), B<sched_get_priority_max>(2), "
2919 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), "
2920 "B<sched_getscheduler>(2), B<sched_setaffinity>(2), B<sched_setscheduler>(2), "
2921 "B<setpriority>(2), B<capabilities>(7)"
2925 #: build/C/man2/sched_setscheduler.2:46
2927 msgid "SCHED_SETSCHEDULER"
2931 #: build/C/man2/sched_setscheduler.2:50
2933 "sched_setscheduler, sched_getscheduler - set and get scheduling "
2938 #: build/C/man2/sched_setscheduler.2:55
2940 msgid "B<int sched_setscheduler(pid_t >I<pid>B<, int >I<policy>B<,>\n"
2944 #: build/C/man2/sched_setscheduler.2:57
2946 msgid "B< const struct sched_param *>I<param>B<);>\n"
2950 #: build/C/man2/sched_setscheduler.2:59
2952 msgid "B<int sched_getscheduler(pid_t >I<pid>B<);>\n"
2956 #: build/C/man2/sched_setscheduler.2:76
2958 "B<sched_setscheduler>() sets both the scheduling policy and the associated "
2959 "parameters for the process whose ID is specified in I<pid>. If I<pid> "
2960 "equals zero, the scheduling policy and parameters of the calling process "
2961 "will be set. The interpretation of the argument I<param> depends on the "
2962 "selected policy. Currently, Linux supports the following \"normal\" (i.e., "
2963 "non-real-time) scheduling policies:"
2967 #: build/C/man2/sched_setscheduler.2:76
2969 msgid "B<SCHED_OTHER>"
2972 #. In the 2.6 kernel sources, SCHED_OTHER is actually called
2975 #: build/C/man2/sched_setscheduler.2:81
2976 msgid "the standard round-robin time-sharing policy;"
2980 #: build/C/man2/sched_setscheduler.2:81
2982 msgid "B<SCHED_BATCH>"
2986 #: build/C/man2/sched_setscheduler.2:84
2987 msgid "for \"batch\" style execution of processes; and"
2991 #: build/C/man2/sched_setscheduler.2:84
2993 msgid "B<SCHED_IDLE>"
2997 #: build/C/man2/sched_setscheduler.2:89
2998 msgid "for running I<very> low priority background jobs."
3002 #: build/C/man2/sched_setscheduler.2:93
3004 "The following \"real-time\" policies are also supported, for special "
3005 "time-critical applications that need precise control over the way in which "
3006 "runnable processes are selected for execution:"
3010 #: build/C/man2/sched_setscheduler.2:93
3012 msgid "B<SCHED_FIFO>"
3016 #: build/C/man2/sched_setscheduler.2:96
3017 msgid "a first-in, first-out policy; and"
3021 #: build/C/man2/sched_setscheduler.2:96
3027 #: build/C/man2/sched_setscheduler.2:99
3028 msgid "a round-robin policy."
3032 #: build/C/man2/sched_setscheduler.2:101
3033 msgid "The semantics of each of these policies are detailed below."
3037 #: build/C/man2/sched_setscheduler.2:108
3039 "B<sched_getscheduler>() queries the scheduling policy currently applied to "
3040 "the process identified by I<pid>. If I<pid> equals zero, the policy of the "
3041 "calling process will be retrieved."
3045 #: build/C/man2/sched_setscheduler.2:108
3047 msgid "Scheduling policies"
3051 #: build/C/man2/sched_setscheduler.2:117
3053 "The scheduler is the kernel component that decides which runnable process "
3054 "will be executed by the CPU next. Each process has an associated scheduling "
3055 "policy and a I<static> scheduling priority, I<sched_priority>; these are the "
3056 "settings that are modified by B<sched_setscheduler>(). The scheduler makes "
3057 "it decisions based on knowledge of the scheduling policy and static priority "
3058 "of all processes on the system."
3062 #: build/C/man2/sched_setscheduler.2:122
3064 "For processes scheduled under one of the normal scheduling policies "
3065 "(B<SCHED_OTHER>, B<SCHED_IDLE>, B<SCHED_BATCH>), I<sched_priority> is not "
3066 "used in scheduling decisions (it must be specified as 0)."
3070 #: build/C/man2/sched_setscheduler.2:136
3072 "Processes scheduled under one of the real-time policies (B<SCHED_FIFO>, "
3073 "B<SCHED_RR>) have a I<sched_priority> value in the range 1 (low) to 99 "
3074 "(high). (As the numbers imply, real-time processes always have higher "
3075 "priority than normal processes.) Note well: POSIX.1-2001 only requires an "
3076 "implementation to support a minimum 32 distinct priority levels for the "
3077 "real-time policies, and some systems supply just this minimum. Portable "
3078 "programs should use B<sched_get_priority_min>(2) and "
3079 "B<sched_get_priority_max>(2) to find the range of priorities supported for "
3080 "a particular policy."
3084 #: build/C/man2/sched_setscheduler.2:142
3086 "Conceptually, the scheduler maintains a list of runnable processes for each "
3087 "possible I<sched_priority> value. In order to determine which process runs "
3088 "next, the scheduler looks for the nonempty list with the highest static "
3089 "priority and selects the process at the head of this list."
3093 #: build/C/man2/sched_setscheduler.2:146
3095 "A process's scheduling policy determines where it will be inserted into the "
3096 "list of processes with equal static priority and how it will move inside "
3101 #: build/C/man2/sched_setscheduler.2:154
3103 "All scheduling is preemptive: if a process with a higher static priority "
3104 "becomes ready to run, the currently running process will be preempted and "
3105 "returned to the wait list for its static priority level. The scheduling "
3106 "policy only determines the ordering within the list of runnable processes "
3107 "with equal static priority."
3111 #: build/C/man2/sched_setscheduler.2:154
3113 msgid "SCHED_FIFO: First in-first out scheduling"
3117 #: build/C/man2/sched_setscheduler.2:163
3119 "B<SCHED_FIFO> can only be used with static priorities higher than 0, which "
3120 "means that when a B<SCHED_FIFO> processes becomes runnable, it will always "
3121 "immediately preempt any currently running B<SCHED_OTHER>, B<SCHED_BATCH>, or "
3122 "B<SCHED_IDLE> process. B<SCHED_FIFO> is a simple scheduling algorithm "
3123 "without time slicing. For processes scheduled under the B<SCHED_FIFO> "
3124 "policy, the following rules apply:"
3128 #: build/C/man2/sched_setscheduler.2:163 build/C/man2/sched_setscheduler.2:168 build/C/man2/sched_setscheduler.2:171 build/C/man2/sched_setscheduler.2:185 build/C/man2/sched_setscheduler.2:287 build/C/man2/sched_setscheduler.2:295 build/C/man2/sched_setscheduler.2:336 build/C/man2/sched_setscheduler.2:344 build/C/man2/sched_setscheduler.2:349 build/C/man2/sched_setscheduler.2:354
3134 #: build/C/man2/sched_setscheduler.2:168
3136 "A B<SCHED_FIFO> process that has been preempted by another process of higher "
3137 "priority will stay at the head of the list for its priority and will resume "
3138 "execution as soon as all processes of higher priority are blocked again."
3142 #: build/C/man2/sched_setscheduler.2:171
3144 "When a B<SCHED_FIFO> process becomes runnable, it will be inserted at the "
3145 "end of the list for its priority."
3148 #. In 2.2.x and 2.4.x, the process is placed at the front of the queue
3149 #. In 2.0.x, the Right Thing happened: the process went to the back -- MTK
3151 #: build/C/man2/sched_setscheduler.2:185
3153 "A call to B<sched_setscheduler>() or B<sched_setparam>(2) will put the "
3154 "B<SCHED_FIFO> (or B<SCHED_RR>) process identified by I<pid> at the start of "
3155 "the list if it was runnable. As a consequence, it may preempt the currently "
3156 "running process if it has the same priority. (POSIX.1-2001 specifies that "
3157 "the process should go to the end of the list.)"
3161 #: build/C/man2/sched_setscheduler.2:189
3162 msgid "A process calling B<sched_yield>(2) will be put at the end of the list."
3166 #: build/C/man2/sched_setscheduler.2:193
3168 "No other events will move a process scheduled under the B<SCHED_FIFO> policy "
3169 "in the wait list of runnable processes with equal static priority."
3173 #: build/C/man2/sched_setscheduler.2:198
3175 "A B<SCHED_FIFO> process runs until either it is blocked by an I/O request, "
3176 "it is preempted by a higher priority process, or it calls B<sched_yield>(2)."
3180 #: build/C/man2/sched_setscheduler.2:198
3182 msgid "SCHED_RR: Round-robin scheduling"
3185 #. On Linux 2.4, the length of the RR interval is influenced
3186 #. by the process nice value -- MTK
3188 #: build/C/man2/sched_setscheduler.2:217
3190 "B<SCHED_RR> is a simple enhancement of B<SCHED_FIFO>. Everything described "
3191 "above for B<SCHED_FIFO> also applies to B<SCHED_RR>, except that each "
3192 "process is only allowed to run for a maximum time quantum. If a B<SCHED_RR> "
3193 "process has been running for a time period equal to or longer than the time "
3194 "quantum, it will be put at the end of the list for its priority. A "
3195 "B<SCHED_RR> process that has been preempted by a higher priority process and "
3196 "subsequently resumes execution as a running process will complete the "
3197 "unexpired portion of its round-robin time quantum. The length of the time "
3198 "quantum can be retrieved using B<sched_rr_get_interval>(2)."
3202 #: build/C/man2/sched_setscheduler.2:217
3204 msgid "SCHED_OTHER: Default Linux time-sharing scheduling"
3208 #: build/C/man2/sched_setscheduler.2:233
3210 "B<SCHED_OTHER> can only be used at static priority 0. B<SCHED_OTHER> is the "
3211 "standard Linux time-sharing scheduler that is intended for all processes "
3212 "that do not require the special real-time mechanisms. The process to run is "
3213 "chosen from the static priority 0 list based on a I<dynamic> priority that "
3214 "is determined only inside this list. The dynamic priority is based on the "
3215 "nice value (set by B<nice>(2) or B<setpriority>(2)) and increased for each "
3216 "time quantum the process is ready to run, but denied to run by the "
3217 "scheduler. This ensures fair progress among all B<SCHED_OTHER> processes."
3221 #: build/C/man2/sched_setscheduler.2:233
3223 msgid "SCHED_BATCH: Scheduling batch processes"
3227 #: build/C/man2/sched_setscheduler.2:245
3229 "(Since Linux 2.6.16.) B<SCHED_BATCH> can only be used at static priority "
3230 "0. This policy is similar to B<SCHED_OTHER> in that it schedules the "
3231 "process according to its dynamic priority (based on the nice value). The "
3232 "difference is that this policy will cause the scheduler to always assume "
3233 "that the process is CPU-intensive. Consequently, the scheduler will apply a "
3234 "small scheduling penalty with respect to wakeup behaviour, so that this "
3235 "process is mildly disfavored in scheduling decisions."
3238 #. The following paragraph is drawn largely from the text that
3239 #. accompanied Ingo Molnar's patch for the implementation of
3242 #: build/C/man2/sched_setscheduler.2:254
3244 "This policy is useful for workloads that are noninteractive, but do not want "
3245 "to lower their nice value, and for workloads that want a deterministic "
3246 "scheduling policy without interactivity causing extra preemptions (between "
3247 "the workload's tasks)."
3251 #: build/C/man2/sched_setscheduler.2:254
3253 msgid "SCHED_IDLE: Scheduling very low priority jobs"
3257 #: build/C/man2/sched_setscheduler.2:258
3259 "(Since Linux 2.6.23.) B<SCHED_IDLE> can only be used at static priority 0; "
3260 "the process nice value has no influence for this policy."
3264 #: build/C/man2/sched_setscheduler.2:266
3266 "This policy is intended for running jobs at extremely low priority (lower "
3267 "even than a +19 nice value with the B<SCHED_OTHER> or B<SCHED_BATCH> "
3272 #: build/C/man2/sched_setscheduler.2:266
3274 msgid "Resetting scheduling policy for child processes"
3278 #: build/C/man2/sched_setscheduler.2:282
3280 "Since Linux 2.6.32, the B<SCHED_RESET_ON_FORK> flag can be ORed in I<policy> "
3281 "when calling B<sched_setscheduler>(). As a result of including this flag, "
3282 "children created by B<fork>(2) do not inherit privileged scheduling "
3283 "policies. This feature is intended for media-playback applications, and can "
3284 "be used to prevent applications evading the B<RLIMIT_RTTIME> resource limit "
3285 "(see B<getrlimit>(2)) by creating multiple child processes."
3289 #: build/C/man2/sched_setscheduler.2:287
3291 "More precisely, if the B<SCHED_RESET_ON_FORK> flag is specified, the "
3292 "following rules apply for subsequently created children:"
3296 #: build/C/man2/sched_setscheduler.2:295
3298 "If the calling process has a scheduling policy of B<SCHED_FIFO> or "
3299 "B<SCHED_RR>, the policy is reset to B<SCHED_OTHER> in child processes."
3303 #: build/C/man2/sched_setscheduler.2:298
3305 "If the calling process has a negative nice value, the nice value is reset to "
3306 "zero in child processes."
3310 #: build/C/man2/sched_setscheduler.2:307
3312 "After the B<SCHED_RESET_ON_FORK> flag has been enabled, it can only be reset "
3313 "if the process has the B<CAP_SYS_NICE> capability. This flag is disabled in "
3314 "child processes created by B<fork>(2)."
3318 #: build/C/man2/sched_setscheduler.2:313
3320 "The B<SCHED_RESET_ON_FORK> flag is visible in the policy value returned by "
3321 "B<sched_getscheduler>()"
3325 #: build/C/man2/sched_setscheduler.2:313
3327 msgid "Privileges and resource limits"
3331 #: build/C/man2/sched_setscheduler.2:326
3333 "In Linux kernels before 2.6.12, only privileged (B<CAP_SYS_NICE>) processes "
3334 "can set a nonzero static priority (i.e., set a real-time scheduling "
3335 "policy). The only change that an unprivileged process can make is to set "
3336 "the B<SCHED_OTHER> policy, and this can only be done if the effective user "
3337 "ID of the caller of B<sched_setscheduler>() matches the real or effective "
3338 "user ID of the target process (i.e., the process specified by I<pid>) whose "
3339 "policy is being changed."
3343 #: build/C/man2/sched_setscheduler.2:336
3345 "Since Linux 2.6.12, the B<RLIMIT_RTPRIO> resource limit defines a ceiling on "
3346 "an unprivileged process's static priority for the B<SCHED_RR> and "
3347 "B<SCHED_FIFO> policies. The rules for changing scheduling policy and "
3348 "priority are as follows:"
3352 #: build/C/man2/sched_setscheduler.2:344
3354 "If an unprivileged process has a nonzero B<RLIMIT_RTPRIO> soft limit, then "
3355 "it can change its scheduling policy and priority, subject to the restriction "
3356 "that the priority cannot be set to a value higher than the maximum of its "
3357 "current priority and its B<RLIMIT_RTPRIO> soft limit."
3361 #: build/C/man2/sched_setscheduler.2:349
3363 "If the B<RLIMIT_RTPRIO> soft limit is 0, then the only permitted changes are "
3364 "to lower the priority, or to switch to a non-real-time policy."
3368 #: build/C/man2/sched_setscheduler.2:354
3370 "Subject to the same rules, another unprivileged process can also make these "
3371 "changes, as long as the effective user ID of the process making the change "
3372 "matches the real or effective user ID of the target process."
3375 #. commit c02aa73b1d18e43cfd79c2f193b225e84ca497c8
3377 #: build/C/man2/sched_setscheduler.2:372
3379 "Special rules apply for the B<SCHED_IDLE>. In Linux kernels before 2.6.39, "
3380 "an unprivileged process operating under this policy cannot change its "
3381 "policy, regardless of the value of its B<RLIMIT_RTPRIO> resource limit. In "
3382 "Linux kernels since 2.6.39, an unprivileged process can switch to either the "
3383 "B<SCHED_BATCH> or the B<SCHED_NORMAL> policy so long as its nice value falls "
3384 "within the range permitted by its B<RLIMIT_NICE> resource limit (see "
3389 #: build/C/man2/sched_setscheduler.2:383
3391 "Privileged (B<CAP_SYS_NICE>) processes ignore the B<RLIMIT_RTPRIO> limit; "
3392 "as with older kernels, they can make arbitrary changes to scheduling policy "
3393 "and priority. See B<getrlimit>(2) for further information on "
3398 #: build/C/man2/sched_setscheduler.2:383
3400 msgid "Response time"
3404 #. .BR request_irq (9).
3406 #: build/C/man2/sched_setscheduler.2:391
3408 "A blocked high priority process waiting for the I/O has a certain response "
3409 "time before it is scheduled again. The device driver writer can greatly "
3410 "reduce this response time by using a \"slow interrupt\" interrupt handler."
3414 #: build/C/man2/sched_setscheduler.2:391
3416 msgid "Miscellaneous"
3420 #: build/C/man2/sched_setscheduler.2:396
3422 "Child processes inherit the scheduling policy and parameters across a "
3423 "B<fork>(2). The scheduling policy and parameters are preserved across "
3428 #: build/C/man2/sched_setscheduler.2:402
3430 "Memory locking is usually needed for real-time processes to avoid paging "
3431 "delays; this can be done with B<mlock>(2) or B<mlockall>(2)."
3435 #: build/C/man2/sched_setscheduler.2:414
3437 "Since a nonblocking infinite loop in a process scheduled under B<SCHED_FIFO> "
3438 "or B<SCHED_RR> will block all processes with lower priority forever, a "
3439 "software developer should always keep available on the console a shell "
3440 "scheduled under a higher static priority than the tested application. This "
3441 "will allow an emergency kill of tested real-time applications that do not "
3442 "block or terminate as expected. See also the description of the "
3443 "B<RLIMIT_RTTIME> resource limit in B<getrlimit>(2)."
3447 #: build/C/man2/sched_setscheduler.2:422
3449 "POSIX systems on which B<sched_setscheduler>() and B<sched_getscheduler>() "
3450 "are available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3454 #: build/C/man2/sched_setscheduler.2:432
3456 "On success, B<sched_setscheduler>() returns zero. On success, "
3457 "B<sched_getscheduler>() returns the policy for the process (a nonnegative "
3458 "integer). On error, -1 is returned, and I<errno> is set appropriately."
3462 #: build/C/man2/sched_setscheduler.2:438
3464 "The scheduling I<policy> is not one of the recognized policies, I<param> is "
3465 "NULL, or I<param> does not make sense for the I<policy>."
3469 #: build/C/man2/sched_setscheduler.2:441
3470 msgid "The calling process does not have appropriate privileges."
3474 #: build/C/man2/sched_setscheduler.2:447
3476 "POSIX.1-2001 (but see BUGS below). The B<SCHED_BATCH> and B<SCHED_IDLE> "
3477 "policies are Linux-specific."
3481 #: build/C/man2/sched_setscheduler.2:455
3483 "POSIX.1 does not detail the permissions that an unprivileged process "
3484 "requires in order to call B<sched_setscheduler>(), and details vary across "
3485 "systems. For example, the Solaris 7 manual page says that the real or "
3486 "effective user ID of the calling process must match the real user ID or the "
3487 "save set-user-ID of the target process."
3491 #: build/C/man2/sched_setscheduler.2:476
3493 "The scheduling policy and parameters are in fact per-thread attributes on "
3494 "Linux. The value returned from a call to B<gettid>(2) can be passed in the "
3495 "argument I<pid>. Specifying I<pid> as 0 will operate on the attribute for "
3496 "the calling thread, and passing the value returned from a call to "
3497 "B<getpid>(2) will operate on the attribute for the main thread of the "
3498 "thread group. (If you are using the POSIX threads API, then use "
3499 "B<pthread_setschedparam>(3), B<pthread_getschedparam>(3), and "
3500 "B<pthread_setschedprio>(3), instead of the B<sched_*>(2) system calls.)"
3504 #: build/C/man2/sched_setscheduler.2:486
3506 "Originally, Standard Linux was intended as a general-purpose operating "
3507 "system being able to handle background processes, interactive applications, "
3508 "and less demanding real-time applications (applications that need to usually "
3509 "meet timing deadlines). Although the Linux kernel 2.6 allowed for kernel "
3510 "preemption and the newly introduced O(1) scheduler ensures that the time "
3511 "needed to schedule is fixed and deterministic irrespective of the number of "
3512 "active tasks, true real-time computing was not possible up to kernel version "
3517 #: build/C/man2/sched_setscheduler.2:486
3519 msgid "Real-time features in the mainline Linux kernel"
3522 #. FIXME . Probably this text will need some minor tweaking
3523 #. by about the time of 2.6.30; ask Carsten Emde about this then.
3525 #: build/C/man2/sched_setscheduler.2:500
3527 "From kernel version 2.6.18 onward, however, Linux is gradually becoming "
3528 "equipped with real-time capabilities, most of which are derived from the "
3529 "former I<realtime-preempt> patches developed by Ingo Molnar, Thomas "
3530 "Gleixner, Steven Rostedt, and others. Until the patches have been "
3531 "completely merged into the mainline kernel (this is expected to be around "
3532 "kernel version 2.6.30), they must be installed to achieve the best real-time "
3533 "performance. These patches are named:"
3537 #: build/C/man2/sched_setscheduler.2:504
3539 msgid "patch-I<kernelversion>-rtI<patchversion>\n"
3543 #: build/C/man2/sched_setscheduler.2:510
3545 "and can be downloaded from E<.UR "
3546 "http://www.kernel.org\\:/pub\\:/linux\\:/kernel\\:/projects\\:/rt/> E<.UE .>"
3550 #: build/C/man2/sched_setscheduler.2:519
3552 "Without the patches and prior to their full inclusion into the mainline "
3553 "kernel, the kernel configuration offers only the three preemption classes "
3554 "B<CONFIG_PREEMPT_NONE>, B<CONFIG_PREEMPT_VOLUNTARY>, and "
3555 "B<CONFIG_PREEMPT_DESKTOP> which respectively provide no, some, and "
3556 "considerable reduction of the worst-case scheduling latency."
3560 #: build/C/man2/sched_setscheduler.2:530
3562 "With the patches applied or after their full inclusion into the mainline "
3563 "kernel, the additional configuration item B<CONFIG_PREEMPT_RT> becomes "
3564 "available. If this is selected, Linux is transformed into a regular "
3565 "real-time operating system. The FIFO and RR scheduling policies that can be "
3566 "selected using B<sched_setscheduler>() are then used to run a process with "
3567 "true real-time priority and a minimum worst-case scheduling latency."
3571 #: build/C/man2/sched_setscheduler.2:538
3573 "POSIX says that on success, B<sched_setscheduler>() should return the "
3574 "previous scheduling policy. Linux B<sched_setscheduler>() does not conform "
3575 "to this requirement, since it always returns 0 on success."
3579 #: build/C/man2/sched_setscheduler.2:559
3581 "B<chrt>(1), B<getpriority>(2), B<mlock>(2), B<mlockall>(2), B<munlock>(2), "
3582 "B<munlockall>(2), B<nice>(2), B<sched_get_priority_max>(2), "
3583 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), B<sched_getparam>(2), "
3584 "B<sched_rr_get_interval>(2), B<sched_setaffinity>(2), B<sched_setparam>(2), "
3585 "B<sched_yield>(2), B<setpriority>(2), B<capabilities>(7), B<cpuset>(7)"
3589 #: build/C/man2/sched_setscheduler.2:567
3591 "I<Documentation/scheduler/sched-rt-group.txt> in the Linux kernel source "
3592 "tree (since kernel 2.6.25)."
3596 #: build/C/man2/sched_yield.2:29
3602 #: build/C/man2/sched_yield.2:29
3608 #: build/C/man2/sched_yield.2:32
3609 msgid "sched_yield - yield the processor"
3613 #: build/C/man2/sched_yield.2:36
3614 msgid "B<int sched_yield(void);>"
3618 #: build/C/man2/sched_yield.2:41
3620 "B<sched_yield>() causes the calling thread to relinquish the CPU. The "
3621 "thread is moved to the end of the queue for its static priority and a new "
3622 "thread gets to run."
3626 #: build/C/man2/sched_yield.2:48
3628 "On success, B<sched_yield>() returns 0. On error, -1 is returned, and "
3629 "I<errno> is set appropriately."
3633 #: build/C/man2/sched_yield.2:52
3634 msgid "In the Linux implementation, B<sched_yield>() always succeeds."
3638 #: build/C/man2/sched_yield.2:59
3640 "If the calling thread is the only thread in the highest priority list at "
3641 "that time, it will continue to run after a call to B<sched_yield>()."
3645 #: build/C/man2/sched_yield.2:65
3647 "POSIX systems on which B<sched_yield>() is available define "
3648 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3652 #: build/C/man2/sched_yield.2:78
3654 "Strategic calls to B<sched_yield>() can improve performance by giving other "
3655 "threads or processes a chance to run when (heavily) contended resources "
3656 "(e.g., mutexes) have been released by the caller. Avoid calling "
3657 "B<sched_yield>() unnecessarily or inappropriately (e.g., when resources "
3658 "needed by other schedulable threads are still held by the caller), since "
3659 "doing so will result in unnecessary context switches, which will degrade "
3660 "system performance."
3664 #: build/C/man2/sched_yield.2:81
3665 msgid "B<sched_setscheduler>(2) for a description of Linux scheduling"
3669 #: build/C/man2/setns.2:8
3675 #: build/C/man2/setns.2:11
3676 msgid "setns - reassociate thread with a namespace"
3680 #: build/C/man2/setns.2:17
3682 msgid "B<int setns(int >I<fd>B<, int >I<nstype>B<);>\n"
3686 #: build/C/man2/setns.2:21
3688 "Given a file descriptor referring to a namespace, reassociate the calling "
3689 "thread with that namespace."
3693 #: build/C/man2/setns.2:34
3695 "The I<fd> argument is a file descriptor referring to one of the namespace "
3696 "entries in a I</proc/[pid]/ns/> directory; see B<proc>(5) for further "
3697 "information on I</proc/[pid]/ns/>. The calling thread will be reassociated "
3698 "with the corresponding namespace, subject to any constraints imposed by the "
3699 "I<nstype> argument."
3703 #: build/C/man2/setns.2:40
3705 "The I<nstype> argument specifies which type of namespace the calling thread "
3706 "may be reassociated with. This argument can have one of the following "
3711 #: build/C/man2/setns.2:40
3717 #: build/C/man2/setns.2:43
3718 msgid "Allow any type of namespace to be joined."
3722 #: build/C/man2/setns.2:43
3724 msgid "B<CLONE_NEWIPC>"
3728 #: build/C/man2/setns.2:47
3729 msgid "I<fd> must refer to an IPC namespace."
3733 #: build/C/man2/setns.2:47
3735 msgid "B<CLONE_NEWNET>"
3739 #: build/C/man2/setns.2:51
3740 msgid "I<fd> must refer to a network namespace."
3744 #: build/C/man2/setns.2:51
3746 msgid "B<CLONE_NEWUTS>"
3750 #: build/C/man2/setns.2:55
3751 msgid "I<fd> must refer to a UTS namespace."
3755 #: build/C/man2/setns.2:70
3757 "Specifying I<nstype> as 0 suffices if the caller knows (or does not care) "
3758 "what type of namespace is referred to by I<fd>. Specifying a nonzero value "
3759 "for I<nstype> is useful if the caller does not know what type of namespace "
3760 "is referred to by I<fd> and wants to ensure that the namespace is of a "
3761 "particular type. (The caller might not know the type of the namespace "
3762 "referred to by I<fd> if the file descriptor was opened by another process "
3763 "and, for example, passed to the caller via a UNIX domain socket.)"
3767 #: build/C/man2/setns.2:77
3769 "On success, I<setns>() returns 0. On failure, -1 is returned and I<errno> "
3770 "is set to indicate the error."
3774 #: build/C/man2/setns.2:82
3775 msgid "I<fd> is not a valid file descriptor."
3779 #: build/C/man2/setns.2:89
3781 "I<fd> refers to a namespace whose type does not match that specified in "
3782 "I<nstype>, or there is problem with reassociating the the thread with the "
3783 "specified namespace."
3787 #: build/C/man2/setns.2:92
3788 msgid "Cannot allocate sufficient memory to change the specified namespace."
3792 #: build/C/man2/setns.2:97
3794 "The calling thread did not have the required privilege (B<CAP_SYS_ADMIN>) "
3795 "for this operation."
3799 #: build/C/man2/setns.2:102
3801 "The B<setns>() system call first appeared in Linux in kernel 3.0; library "
3802 "support was added to glibc in version 2.14."
3806 #: build/C/man2/setns.2:106
3807 msgid "The B<setns>() system call is Linux-specific."
3811 #: build/C/man2/setns.2:112
3813 "Not all of the attributes that can be shared when a new thread is created "
3814 "using B<clone>(2) can be changed using B<setns>()."
3818 #: build/C/man2/setns.2:121
3820 "The program below takes two or more arguments. The first argument specifies "
3821 "the pathname of a namespace file in an existing I</proc/[pid]/ns/> "
3822 "directory. The remaining arguments specify a command and its arguments. "
3823 "The program opens the namespace file, joins that namespace using B<setns>(), "
3824 "and executes the specified command inside that namespace."
3828 #: build/C/man2/setns.2:131
3830 "The following shell session demonstrates the use of this program (compiled "
3831 "as a binary named I<ns_exec>) in conjunction with the B<CLONE_NEWUTS> "
3832 "example program in the B<clone>(2) man page (complied as a binary named "
3837 #: build/C/man2/setns.2:139
3839 "We begin by executing the example program in B<clone>(2) in the "
3840 "background. That program creates a child in a separate UTS namespace. The "
3841 "child changes the hostname in its namespace, and then both processes display "
3842 "the hostnames in their UTS namespaces, so that we can see that they are "
3847 #: build/C/man2/setns.2:151
3850 "$ B<su> # Need privilege for namespace operations\n"
3852 "# B<./newuts bizarro &>\n"
3854 "clone() returned 3550\n"
3855 "uts.nodename in child: bizarro\n"
3856 "uts.nodename in parent: antero\n"
3857 "# B<uname -n> # Verify hostname in the shell\n"
3862 #: build/C/man2/setns.2:158
3864 "We then run the program shown below, using it to execute a shell. Inside "
3865 "that shell, we verify that the hostname is the one set by the child created "
3866 "by the first program:"
3870 #: build/C/man2/setns.2:164
3873 "# B<./ns_exec /proc/3550/ns/uts /bin/bash>\n"
3874 "# B<uname -n> # Executed in shell started by ns_exec\n"
3879 #: build/C/man2/setns.2:166
3881 msgid "Program source"
3885 #: build/C/man2/setns.2:174
3888 "#define _GNU_SOURCE\n"
3889 "#include E<lt>fcntl.hE<gt>\n"
3890 "#include E<lt>sched.hE<gt>\n"
3891 "#include E<lt>unistd.hE<gt>\n"
3892 "#include E<lt>stdlib.hE<gt>\n"
3893 "#include E<lt>stdio.hE<gt>\n"
3897 #: build/C/man2/setns.2:182
3901 "main(int argc, char *argv[])\n"
3907 #: build/C/man2/setns.2:187
3910 " if (argc E<lt> 3) {\n"
3911 " fprintf(stderr, \"%s /proc/PID/ns/FILE cmd args...\\en\", "
3913 " exit(EXIT_FAILURE);\n"
3918 #: build/C/man2/setns.2:191
3921 " fd = open(argv[1], O_RDONLY); /* Get descriptor for namespace */\n"
3923 " errExit(\"open\");\n"
3927 #: build/C/man2/setns.2:194
3930 " if (setns(fd, 0) == -1) /* Join that namespace */\n"
3931 " errExit(\"setns\");\n"
3935 #: build/C/man2/setns.2:198
3938 " execvp(argv[2], &argv[2]); /* Execute a command in namespace */\n"
3939 " errExit(\"execvp\");\n"
3944 #: build/C/man2/setns.2:205
3945 msgid "B<clone>(2), B<fork>(2), B<vfork>(2), B<proc>(5), B<unix>(7)"
3949 #: build/C/man2/unshare.2:20
3955 #: build/C/man2/unshare.2:20
3961 #: build/C/man2/unshare.2:23
3962 msgid "unshare - disassociate parts of the process execution context"
3966 #: build/C/man2/unshare.2:31
3968 msgid "B<int unshare(int >I<flags>B<);>\n"
3972 #: build/C/man2/unshare.2:44
3974 "B<unshare>() allows a process to disassociate parts of its execution "
3975 "context that are currently being shared with other processes. Part of the "
3976 "execution context, such as the mount namespace, is shared implicitly when a "
3977 "new process is created using B<fork>(2) or B<vfork>(2), while other parts, "
3978 "such as virtual memory, may be shared by explicit request when creating a "
3979 "process using B<clone>(2)."
3983 #: build/C/man2/unshare.2:49
3985 "The main use of B<unshare>() is to allow a process to control its shared "
3986 "execution context without creating a new process."
3990 #: build/C/man2/unshare.2:56
3992 "The I<flags> argument is a bit mask that specifies which parts of the "
3993 "execution context should be unshared. This argument is specified by ORing "
3994 "together zero or more of the following constants:"
3998 #: build/C/man2/unshare.2:56
4000 msgid "B<CLONE_FILES>"
4004 #: build/C/man2/unshare.2:64
4006 "Reverse the effect of the B<clone>(2) B<CLONE_FILES> flag. Unshare the "
4007 "file descriptor table, so that the calling process no longer shares its file "
4008 "descriptors with any other process."
4012 #: build/C/man2/unshare.2:64
4018 #: build/C/man2/unshare.2:78
4020 "Reverse the effect of the B<clone>(2) B<CLONE_FS> flag. Unshare file "
4021 "system attributes, so that the calling process no longer shares its root "
4022 "directory (B<chroot>(2)), current directory (B<chdir>(2)), or umask "
4023 "(B<umask>(2)) attributes with any other process."
4027 #: build/C/man2/unshare.2:95
4029 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWIPC> flag. "
4030 "Unshare the System V IPC namespace, so that the calling process has a "
4031 "private copy of the System V IPC namespace which is not shared with any "
4032 "other process. Specifying this flag automatically implies B<CLONE_SYSVSEM> "
4033 "as well. Use of B<CLONE_NEWIPC> requires the B<CAP_SYS_ADMIN> capability."
4037 #: build/C/man2/unshare.2:110
4039 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNET> flag. "
4040 "Unshare the network namespace, so that the calling process is moved into a "
4041 "new network namespace which is not shared with any previously existing "
4042 "process. Use of B<CLONE_NEWNET> requires the B<CAP_SYS_ADMIN> capability."
4046 #: build/C/man2/unshare.2:110
4048 msgid "B<CLONE_NEWNS>"
4051 #. These flag name are inconsistent:
4052 #. CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
4053 #. CLONE_FS, and CLONE_FILES reverse the action of the clone()
4054 #. flags of the same name.
4056 #: build/C/man2/unshare.2:131
4058 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNS> flag. "
4059 "Unshare the mount namespace, so that the calling process has a private copy "
4060 "of its namespace which is not shared with any other process. Specifying "
4061 "this flag automatically implies B<CLONE_FS> as well. Use of B<CLONE_NEWNS> "
4062 "requires the B<CAP_SYS_ADMIN> capability."
4066 #: build/C/man2/unshare.2:145
4068 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWUTS> flag. "
4069 "Unshare the UTS IPC namespace, so that the calling process has a private "
4070 "copy of the UTS namespace which is not shared with any other process. Use "
4071 "of B<CLONE_NEWUTS> requires the B<CAP_SYS_ADMIN> capability."
4075 #: build/C/man2/unshare.2:145
4077 msgid "B<CLONE_SYSVSEM> (since Linux 2.6.26)"
4080 #. commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7
4081 #. As at 2.6.16, the following forced implications also apply,
4082 #. although the relevant flags are not yet implemented.
4083 #. If CLONE_THREAD is set force CLONE_VM.
4084 #. If CLONE_VM is set, force CLONE_SIGHAND.
4085 #. CLONE_NEWNSIf CLONE_SIGHAND is set and signals are also being shared
4086 #. (i.e., current->signal->count > 1), force CLONE_THREAD.
4088 #. FIXME . CLONE_VM is not (yet, as at 2.6.16) implemented.
4091 #. Reverse the effect of the
4096 #. is also implicitly set by
4098 #. and can be reversed using this
4101 #. Unshare virtual memory, so that the calling process no
4102 #. longer shares its virtual address space with any other process.
4104 #: build/C/man2/unshare.2:182
4106 "This flag reverses the effect of the B<clone>(2) B<CLONE_SYSVSEM> flag. "
4107 "Unshare System V semaphore undo values, so that the calling process has a "
4108 "private copy which is not shared with any other process. Use of "
4109 "B<CLONE_SYSVSEM> requires the B<CAP_SYS_ADMIN> capability."
4113 #: build/C/man2/unshare.2:189
4115 "If I<flags> is specified as zero, then B<unshare>() is a no-op; no changes "
4116 "are made to the calling process's execution context."
4120 #: build/C/man2/unshare.2:194
4122 "On success, zero returned. On failure, -1 is returned and I<errno> is set "
4123 "to indicate the error."
4127 #: build/C/man2/unshare.2:199
4128 msgid "An invalid bit was specified in I<flags>."
4132 #: build/C/man2/unshare.2:203
4134 "Cannot allocate sufficient memory to copy parts of caller's context that "
4135 "need to be unshared."
4139 #: build/C/man2/unshare.2:206
4140 msgid "The calling process did not have the required privileges for this operation."
4144 #: build/C/man2/unshare.2:210
4145 msgid "The B<unshare>() system call was added to Linux in kernel 2.6.16."
4149 #: build/C/man2/unshare.2:214
4150 msgid "The B<unshare>() system call is Linux-specific."
4153 #. FIXME all of the following needs to be reviewed for the current kernel
4154 #. However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
4155 #. was not specified when doing clone(); i.e., unsharing
4156 #. signal handlers is permitted if we are not actually
4157 #. sharing signal handlers. mtk
4158 #. However, we can do unshare(CLONE_VM) if CLONE_VM
4159 #. was not specified when doing clone(); i.e., unsharing
4160 #. virtual memory is permitted if we are not actually
4161 #. sharing virtual memory. mtk
4165 #. The current implementation of unshare does not allow unsharing of
4166 #. signals and signal handlers. Signals are complex to begin with and
4167 #. to unshare signals and/or signal handlers of a currently running
4168 #. process is even more complex. If in the future there is a specific
4169 #. need to allow unsharing of signals and/or signal handlers, it can
4170 #. be incrementally added to unshare without affecting legacy
4171 #. applications using unshare.
4173 #: build/C/man2/unshare.2:248
4175 "Not all of the process attributes that can be shared when a new process is "
4176 "created using B<clone>(2) can be unshared using B<unshare>(). In "
4177 "particular, as at kernel 3.8, B<unshare>() does not implement flags that "
4178 "reverse the effects of B<CLONE_SIGHAND>, B<CLONE_THREAD>, or B<CLONE_VM>. "
4179 "Such functionality may be added in the future, if required."
4183 #: build/C/man2/unshare.2:254
4184 msgid "B<clone>(2), B<fork>(2), B<kcmp>(2), B<setns>(2), B<vfork>(2)"
4188 #: build/C/man2/unshare.2:257
4189 msgid "I<Documentation/unshare.txt> in the Linux kernel source tree"