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: 2015-02-04 23:33+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=UTF-8\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:42 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_setattr.2:26 build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:26 build/C/man2/sched_yield.2:29 build/C/man7/sched.7:32 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:42 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_setattr.2:26 build/C/man2/sched_setparam.2:30 build/C/man2/sched_setscheduler.2:26 build/C/man2/sched_yield.2:29 build/C/man7/sched.7:32 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:43 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_setattr.2:27 build/C/man2/sched_setparam.2:31 build/C/man2/sched_setscheduler.2:27 build/C/man2/sched_yield.2:30 build/C/man7/sched.7:33 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:45 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_setattr.2:30 build/C/man2/sched_setparam.2:33 build/C/man2/sched_setscheduler.2:30 build/C/man2/sched_yield.2:32 build/C/man2/setns.2:11 build/C/man2/unshare.2:23
65 #: build/C/man3/CPU_SET.3:39 build/C/man2/sched_setaffinity.2:42 build/C/man2/setns.2:15
68 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
69 "B<#include E<lt>sched.hE<gt>>\n"
73 #: build/C/man3/CPU_SET.3:41
75 msgid "B<void CPU_ZERO(cpu_set_t *>I<set>B<);>\n"
79 #: build/C/man3/CPU_SET.3:45
82 "B<void CPU_SET(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
83 "B<void CPU_CLR(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
84 "B<int CPU_ISSET(int >I<cpu>B<, cpu_set_t *>I<set>B<);>\n"
88 #: build/C/man3/CPU_SET.3:47
90 msgid "B<int CPU_COUNT(cpu_set_t *>I<set>B<);>\n"
94 #: build/C/man3/CPU_SET.3:54
97 "B<void CPU_AND(cpu_set_t *>I<destset>B<,>\n"
98 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
99 "B<void CPU_OR(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_XOR(cpu_set_t *>I<destset>B<,>\n"
102 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
106 #: build/C/man3/CPU_SET.3:56
108 msgid "B<int CPU_EQUAL(cpu_set_t *>I<set1>B<, cpu_set_t *>I<set2>B<);>\n"
112 #: build/C/man3/CPU_SET.3:60
115 "B<cpu_set_t *CPU_ALLOC(int >I<num_cpus>B<);>\n"
116 "B<void CPU_FREE(cpu_set_t *>I<set>B<);>\n"
117 "B<size_t CPU_ALLOC_SIZE(int >I<num_cpus>B<);>\n"
121 #: build/C/man3/CPU_SET.3:62
123 msgid "B<void CPU_ZERO_S(size_t >I<setsize>B<, cpu_set_t *>I<set>B<);>\n"
127 #: build/C/man3/CPU_SET.3:66
130 "B<void CPU_SET_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
132 "B<void CPU_CLR_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
134 "B<int CPU_ISSET_S(int >I<cpu>B<, size_t >I<setsize>B<, cpu_set_t "
139 #: build/C/man3/CPU_SET.3:68
141 msgid "B<int CPU_COUNT_S(size_t >I<setsize>B<, cpu_set_t *>I<set>B<);>\n"
145 #: build/C/man3/CPU_SET.3:75
148 "B<void CPU_AND_S(size_t >I<setsize>B<, cpu_set_t *>I<destset>B<,>\n"
149 "B< cpu_set_t *>I<srcset1>B<, cpu_set_t *>I<srcset2>B<);>\n"
150 "B<void CPU_OR_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_XOR_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"
157 #: build/C/man3/CPU_SET.3:78
160 "B<int CPU_EQUAL_S(size_t >I<setsize>B<, cpu_set_t *>I<set1>B<, cpu_set_t "
165 #: build/C/man3/CPU_SET.3:79 build/C/man2/clone.2:83 build/C/man2/kcmp.2:41 build/C/man2/sched_get_priority_max.2:38 build/C/man3/sched_getcpu.3:55 build/C/man2/sched_rr_get_interval.2:36 build/C/man2/sched_setaffinity.2:49 build/C/man2/sched_setattr.2:41 build/C/man2/sched_setparam.2:47 build/C/man2/sched_setscheduler.2:41 build/C/man2/sched_yield.2:36 build/C/man7/sched.7:35 build/C/man2/setns.2:18 build/C/man2/unshare.2:50
171 #: build/C/man3/CPU_SET.3:86
173 "The I<cpu_set_t> data structure represents a set of CPUs. CPU sets are used "
174 "by B<sched_setaffinity>(2) and similar interfaces."
178 #: build/C/man3/CPU_SET.3:93
180 "The I<cpu_set_t> data type is implemented as a bit set. However, the data "
181 "structure treated as considered opaque: all manipulation of CPU sets should "
182 "be done via the macros described in this page."
186 #: build/C/man3/CPU_SET.3:96
187 msgid "The following macros are provided to operate on the CPU set I<set>:"
191 #: build/C/man3/CPU_SET.3:96
193 msgid "B<CPU_ZERO>()"
197 #: build/C/man3/CPU_SET.3:101
198 msgid "Clears I<set>, so that it contains no CPUs."
202 #: build/C/man3/CPU_SET.3:101
208 #: build/C/man3/CPU_SET.3:107
209 msgid "Add CPU I<cpu> to I<set>."
213 #: build/C/man3/CPU_SET.3:107
219 #: build/C/man3/CPU_SET.3:113
220 msgid "Remove CPU I<cpu> from I<set>."
224 #: build/C/man3/CPU_SET.3:113
226 msgid "B<CPU_ISSET>()"
230 #: build/C/man3/CPU_SET.3:119
231 msgid "Test to see if CPU I<cpu> is a member of I<set>."
235 #: build/C/man3/CPU_SET.3:119
237 msgid "B<CPU_COUNT>()"
241 #: build/C/man3/CPU_SET.3:123
242 msgid "Return the number of CPUs in I<set>."
246 #: build/C/man3/CPU_SET.3:128
248 "Where a I<cpu> argument is specified, it should not produce side effects, "
249 "since the above macros may evaluate the argument more than once."
253 #: build/C/man3/CPU_SET.3:139
255 "The first available CPU on the system corresponds to a I<cpu> value of 0, "
256 "the next CPU corresponds to a I<cpu> value of 1, and so on. The constant "
257 "B<CPU_SETSIZE> (currently 1024) specifies a value one greater than the "
258 "maximum CPU number that can be stored in I<cpu_set_t>."
262 #: build/C/man3/CPU_SET.3:141
263 msgid "The following macros perform logical operations on CPU sets:"
267 #: build/C/man3/CPU_SET.3:141
273 #: build/C/man3/CPU_SET.3:150
275 "Store the intersection of the sets I<srcset1> and I<srcset2> in I<destset> "
276 "(which may be one of the source sets)."
280 #: build/C/man3/CPU_SET.3:150
286 #: build/C/man3/CPU_SET.3:159
288 "Store the union of the sets I<srcset1> and I<srcset2> in I<destset> (which "
289 "may be one of the source sets)."
293 #: build/C/man3/CPU_SET.3:159
299 #: build/C/man3/CPU_SET.3:173
301 "Store the XOR of the sets I<srcset1> and I<srcset2> in I<destset> (which may "
302 "be one of the source sets). The XOR means the set of CPUs that are in "
303 "either I<srcset1> or I<srcset2>, but not both."
307 #: build/C/man3/CPU_SET.3:173
309 msgid "B<CPU_EQUAL>()"
313 #: build/C/man3/CPU_SET.3:176
314 msgid "Test whether two CPU set contain exactly the same CPUs."
318 #: build/C/man3/CPU_SET.3:176
320 msgid "Dynamically sized CPU sets"
324 #: build/C/man3/CPU_SET.3:182
326 "Because some applications may require the ability to dynamically size CPU "
327 "sets (e.g., to allocate sets larger than that defined by the standard "
328 "I<cpu_set_t> data type), glibc nowadays provides a set of macros to support "
333 #: build/C/man3/CPU_SET.3:184
334 msgid "The following macros are used to allocate and deallocate CPU sets:"
338 #: build/C/man3/CPU_SET.3:184
340 msgid "B<CPU_ALLOC>()"
344 #: build/C/man3/CPU_SET.3:189
346 "Allocate a CPU set large enough to hold CPUs in the range 0 to "
351 #: build/C/man3/CPU_SET.3:189
353 msgid "B<CPU_ALLOC_SIZE>()"
357 #: build/C/man3/CPU_SET.3:199
359 "Return the size in bytes of the CPU set that would be needed to hold CPUs in "
360 "the range 0 to I<num_cpus-1>. This macro provides the value that can be "
361 "used for the I<setsize> argument in the B<CPU_*_S>() macros described "
366 #: build/C/man3/CPU_SET.3:199
368 msgid "B<CPU_FREE>()"
372 #: build/C/man3/CPU_SET.3:203
373 msgid "Free a CPU set previously allocated by B<CPU_ALLOC>()."
377 #: build/C/man3/CPU_SET.3:210
379 "The macros whose names end with \"_S\" are the analogs of the similarly "
380 "named macros without the suffix. These macros perform the same tasks as "
381 "their analogs, but operate on the dynamically allocated CPU set(s) whose "
382 "size is I<setsize> bytes."
386 #: build/C/man3/CPU_SET.3:210 build/C/man2/clone.2:873 build/C/man2/kcmp.2:127 build/C/man2/sched_get_priority_max.2:97 build/C/man3/sched_getcpu.3:58 build/C/man2/sched_rr_get_interval.2:73 build/C/man2/sched_setaffinity.2:107 build/C/man2/sched_setattr.2:262 build/C/man2/sched_setparam.2:87 build/C/man2/sched_setscheduler.2:135 build/C/man2/sched_yield.2:41 build/C/man2/setns.2:138 build/C/man2/unshare.2:277
392 #: build/C/man3/CPU_SET.3:219
394 "B<CPU_ISSET>() and B<CPU_ISSET_S>() return nonzero if I<cpu> is in I<set>; "
395 "otherwise, it returns 0."
399 #: build/C/man3/CPU_SET.3:225
400 msgid "B<CPU_COUNT>() and B<CPU_COUNT_S>() return the number of CPUs in I<set>."
404 #: build/C/man3/CPU_SET.3:230
406 "B<CPU_EQUAL>() and B<CPU_EQUAL_S>() return nonzero if the two CPU sets are "
407 "equal; otherwise it returns 0."
411 #: build/C/man3/CPU_SET.3:235
413 "B<CPU_ALLOC>() returns a pointer on success, or NULL on failure. (Errors "
414 "are as for B<malloc>(3).)"
418 #: build/C/man3/CPU_SET.3:239
420 "B<CPU_ALLOC_SIZE>() returns the number of bytes required to store a CPU set "
421 "of the specified cardinality."
425 #: build/C/man3/CPU_SET.3:241
426 msgid "The other functions do not return a value."
430 #: build/C/man3/CPU_SET.3:241 build/C/man2/clone.2:1031 build/C/man2/kcmp.2:198 build/C/man3/sched_getcpu.3:70 build/C/man2/sched_setaffinity.2:148 build/C/man2/sched_setattr.2:348 build/C/man2/setns.2:186 build/C/man2/unshare.2:330
436 #: build/C/man3/CPU_SET.3:249
438 "The B<CPU_ZERO>(), B<CPU_SET>(), B<CPU_CLR>(), and B<CPU_ISSET>() macros "
439 "were added in glibc 2.3.3."
443 #: build/C/man3/CPU_SET.3:252
444 msgid "B<CPU_COUNT>() first appeared in glibc 2.6."
448 #: build/C/man3/CPU_SET.3:270
450 "B<CPU_AND>(), B<CPU_OR>(), B<CPU_XOR>(), B<CPU_EQUAL>(), B<CPU_ALLOC>(), "
451 "B<CPU_ALLOC_SIZE>(), B<CPU_FREE>(), B<CPU_ZERO_S>(), B<CPU_SET_S>(), "
452 "B<CPU_CLR_S>(), B<CPU_ISSET_S>(), B<CPU_AND_S>(), B<CPU_OR_S>(), "
453 "B<CPU_XOR_S>(), and B<CPU_EQUAL_S>() first appeared in glibc 2.7."
457 #: build/C/man3/CPU_SET.3:270 build/C/man2/clone.2:1038 build/C/man2/kcmp.2:202 build/C/man2/sched_get_priority_max.2:113 build/C/man3/sched_getcpu.3:77 build/C/man2/sched_rr_get_interval.2:94 build/C/man2/sched_setaffinity.2:159 build/C/man2/sched_setattr.2:351 build/C/man2/sched_setparam.2:119 build/C/man2/sched_setscheduler.2:170 build/C/man2/sched_yield.2:52 build/C/man2/setns.2:191 build/C/man2/unshare.2:334
459 msgid "CONFORMING TO"
463 #: build/C/man3/CPU_SET.3:272
464 msgid "These interfaces are Linux-specific."
468 #: build/C/man3/CPU_SET.3:272 build/C/man2/clone.2:1042 build/C/man2/kcmp.2:205 build/C/man3/sched_getcpu.3:80 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setaffinity.2:161 build/C/man2/sched_setattr.2:353 build/C/man2/sched_setparam.2:121 build/C/man2/sched_setscheduler.2:173 build/C/man2/sched_yield.2:54 build/C/man7/sched.7:611 build/C/man2/setns.2:195 build/C/man2/unshare.2:338
474 #: build/C/man3/CPU_SET.3:275
475 msgid "To duplicate a CPU set, use B<memcpy>(3)."
479 #: build/C/man3/CPU_SET.3:282
481 "Since CPU sets are bit sets allocated in units of long words, the actual "
482 "number of CPUs in a dynamically allocated CPU set will be rounded up to the "
483 "next multiple of I<sizeof(unsigned long)>. An application should consider "
484 "the contents of these extra bits to be undefined."
488 #: build/C/man3/CPU_SET.3:294
490 "Notwithstanding the similarity in the names, note that the constant "
491 "B<CPU_SETSIZE> indicates the number of CPUs in the I<cpu_set_t> data type "
492 "(thus, it is effectively a count of bits in the bit set), while the "
493 "I<setsize> argument of the B<CPU_*_S>() macros is a size in bytes."
497 #: build/C/man3/CPU_SET.3:300
499 "The data types for arguments and return values shown in the SYNOPSIS are "
500 "hints what about is expected in each case. However, since these interfaces "
501 "are implemented as macros, the compiler won't necessarily catch all type "
502 "errors if you violate the suggestions."
506 #: build/C/man3/CPU_SET.3:300 build/C/man2/clone.2:1067 build/C/man2/sched_setattr.2:369 build/C/man2/sched_setscheduler.2:214
511 #. http://sourceware.org/bugzilla/show_bug.cgi?id=7029
513 #: build/C/man3/CPU_SET.3:312
515 "On 32-bit platforms with glibc 2.8 and earlier, B<CPU_ALLOC>() allocates "
516 "twice as much space as is required, and B<CPU_ALLOC_SIZE>() returns a value "
517 "twice as large as it should. This bug should not affect the semantics of a "
518 "program, but does result in wasted memory and less efficient operation of "
519 "the macros that operate on dynamically allocated CPU sets. These bugs are "
520 "fixed in glibc 2.9."
524 #: build/C/man3/CPU_SET.3:312 build/C/man2/clone.2:1109 build/C/man2/setns.2:201 build/C/man2/unshare.2:372
530 #: build/C/man3/CPU_SET.3:315
532 "The following program demonstrates the use of some of the macros used for "
533 "dynamically allocated CPU sets."
537 #: build/C/man3/CPU_SET.3:323
540 "#define _GNU_SOURCE\n"
541 "#include E<lt>sched.hE<gt>\n"
542 "#include E<lt>stdlib.hE<gt>\n"
543 "#include E<lt>unistd.hE<gt>\n"
544 "#include E<lt>stdio.hE<gt>\n"
545 "#include E<lt>assert.hE<gt>\n"
549 #: build/C/man3/CPU_SET.3:330
553 "main(int argc, char *argv[])\n"
555 " cpu_set_t *cpusetp;\n"
557 " int num_cpus, cpu;\n"
561 #: build/C/man3/CPU_SET.3:335
564 " if (argc E<lt> 2) {\n"
565 " fprintf(stderr, \"Usage: %s E<lt>num-cpusE<gt>\\en\", argv[0]);\n"
566 " exit(EXIT_FAILURE);\n"
571 #: build/C/man3/CPU_SET.3:337
573 msgid " num_cpus = atoi(argv[1]);\n"
577 #: build/C/man3/CPU_SET.3:343
580 " cpusetp = CPU_ALLOC(num_cpus);\n"
581 " if (cpusetp == NULL) {\n"
582 " perror(\"CPU_ALLOC\");\n"
583 " exit(EXIT_FAILURE);\n"
588 #: build/C/man3/CPU_SET.3:345
590 msgid " size = CPU_ALLOC_SIZE(num_cpus);\n"
594 #: build/C/man3/CPU_SET.3:349
597 " CPU_ZERO_S(size, cpusetp);\n"
598 " for (cpu = 0; cpu E<lt> num_cpus; cpu += 2)\n"
599 " CPU_SET_S(cpu, size, cpusetp);\n"
603 #: build/C/man3/CPU_SET.3:351
605 msgid " printf(\"CPU_COUNT() of set: %d\\en\", CPU_COUNT_S(size, cpusetp));\n"
609 #: build/C/man3/CPU_SET.3:355
612 " CPU_FREE(cpusetp);\n"
613 " exit(EXIT_SUCCESS);\n"
618 #: build/C/man3/CPU_SET.3:356 build/C/man2/clone.2:1206 build/C/man2/kcmp.2:222 build/C/man2/sched_get_priority_max.2:115 build/C/man3/sched_getcpu.3:100 build/C/man2/sched_rr_get_interval.2:132 build/C/man2/sched_setaffinity.2:226 build/C/man2/sched_setattr.2:385 build/C/man2/sched_setparam.2:127 build/C/man2/sched_setscheduler.2:222 build/C/man2/sched_yield.2:79 build/C/man7/sched.7:664 build/C/man2/setns.2:288 build/C/man2/unshare.2:459
624 #: build/C/man3/CPU_SET.3:361
626 "B<sched_setaffinity>(2), B<pthread_attr_setaffinity_np>(3), "
627 "B<pthread_setaffinity_np>(3), B<cpuset>(7)"
631 #: build/C/man3/CPU_SET.3:361 build/C/man2/clone.2:1221 build/C/man2/kcmp.2:225 build/C/man2/sched_get_priority_max.2:125 build/C/man3/sched_getcpu.3:103 build/C/man2/sched_rr_get_interval.2:134 build/C/man2/sched_setaffinity.2:248 build/C/man2/sched_setattr.2:408 build/C/man2/sched_setparam.2:142 build/C/man2/sched_setscheduler.2:242 build/C/man2/sched_yield.2:81 build/C/man7/sched.7:702 build/C/man2/setns.2:295 build/C/man2/unshare.2:470
637 #: build/C/man3/CPU_SET.3:369 build/C/man2/clone.2:1229 build/C/man2/kcmp.2:233 build/C/man2/sched_get_priority_max.2:133 build/C/man3/sched_getcpu.3:111 build/C/man2/sched_rr_get_interval.2:142 build/C/man2/sched_setaffinity.2:256 build/C/man2/sched_setattr.2:416 build/C/man2/sched_setparam.2:150 build/C/man2/sched_setscheduler.2:250 build/C/man2/sched_yield.2:89 build/C/man7/sched.7:710 build/C/man2/setns.2:303 build/C/man2/unshare.2:478
639 "This page is part of release 3.79 of the Linux I<man-pages> project. A "
640 "description of the project, information about reporting bugs, and the latest "
641 "version of this page, can be found at "
642 "\\%http://www.kernel.org/doc/man-pages/."
646 #: build/C/man2/clone.2:42
652 #: build/C/man2/clone.2:42 build/C/man2/unshare.2:20
658 #: build/C/man2/clone.2:45
659 msgid "clone, __clone2 - create a child process"
663 #: build/C/man2/clone.2:48
665 msgid "/* Prototype for the glibc wrapper function */\n"
669 #: build/C/man2/clone.2:50 build/C/man3/sched_getcpu.3:32 build/C/man2/sched_setattr.2:33 build/C/man2/sched_setparam.2:36 build/C/man2/sched_setscheduler.2:33 build/C/man2/unshare.2:26
671 msgid "B<#include E<lt>sched.hE<gt>>\n"
675 #: build/C/man2/clone.2:55
678 "B<int clone(int (*>I<fn>B<)(void *), void *>I<child_stack>B<,>\n"
679 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
680 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
681 "*>I<ctid>B< */ );>\n"
685 #: build/C/man2/clone.2:57
687 msgid "/* Prototype for the raw system call */\n"
691 #: build/C/man2/clone.2:61
694 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
695 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
696 "B< struct pt_regs *>I<regs>B<);>\n"
700 #: build/C/man2/clone.2:66
702 "Feature Test Macro Requirements for glibc wrapper function (see "
703 "B<feature_test_macros>(7)):"
707 #: build/C/man2/clone.2:69
712 #: build/C/man2/clone.2:72 build/C/man3/sched_getcpu.3:45 build/C/man2/unshare.2:39
714 msgid "Since glibc 2.14:"
718 #: build/C/man2/clone.2:75 build/C/man3/sched_getcpu.3:48 build/C/man2/unshare.2:42
722 #. See http://sources.redhat.com/bugzilla/show_bug.cgi?id=4749
724 #: build/C/man2/clone.2:75 build/C/man3/sched_getcpu.3:48 build/C/man2/unshare.2:42
726 msgid "Before glibc 2.14:"
730 #: build/C/man2/clone.2:80 build/C/man3/sched_getcpu.3:52 build/C/man2/unshare.2:47
733 "_BSD_SOURCE || _SVID_SOURCE\n"
734 " /* _GNU_SOURCE also suffices */\n"
738 #: build/C/man2/clone.2:87
739 msgid "B<clone>() creates a new process, in a manner similar to B<fork>(2)."
743 #: build/C/man2/clone.2:94
745 "This page describes both the glibc B<clone>() wrapper function and the "
746 "underlying system call on which it is based. The main text describes the "
747 "wrapper function; the differences for the raw system call are described "
748 "toward the end of this page."
752 #: build/C/man2/clone.2:106
754 "Unlike B<fork>(2), B<clone>() allows the child process to share parts of "
755 "its execution context with the calling process, such as the memory space, "
756 "the table of file descriptors, and the table of signal handlers. (Note that "
757 "on this manual page, \"calling process\" normally corresponds to \"parent "
758 "process\". But see the description of B<CLONE_PARENT> below.)"
762 #: build/C/man2/clone.2:111
764 "The main use of B<clone>() is to implement threads: multiple threads of "
765 "control in a program that run concurrently in a shared memory space."
769 #: build/C/man2/clone.2:131
771 "When the child process is created with B<clone>(), it executes the function "
772 "I<fn>(I<arg>). (This differs from B<fork>(2), where execution continues in "
773 "the child from the point of the B<fork>(2) call.) The I<fn> argument is a "
774 "pointer to a function that is called by the child process at the beginning "
775 "of its execution. The I<arg> argument is passed to the I<fn> function."
779 #: build/C/man2/clone.2:141
781 "When the I<fn>(I<arg>) function application returns, the child process "
782 "terminates. The integer returned by I<fn> is the exit code for the child "
783 "process. The child process may also terminate explicitly by calling "
784 "B<exit>(2) or after receiving a fatal signal."
788 #: build/C/man2/clone.2:157
790 "The I<child_stack> argument specifies the location of the stack used by the "
791 "child process. Since the child and calling process may share memory, it is "
792 "not possible for the child process to execute in the same stack as the "
793 "calling process. The calling process must therefore set up memory space for "
794 "the child stack and pass a pointer to this space to B<clone>(). Stacks grow "
795 "downward on all processors that run Linux (except the HP PA processors), so "
796 "I<child_stack> usually points to the topmost address of the memory space set "
797 "up for the child stack."
801 #: build/C/man2/clone.2:173
803 "The low byte of I<flags> contains the number of the I<termination signal> "
804 "sent to the parent when the child dies. If this signal is specified as "
805 "anything other than B<SIGCHLD>, then the parent process must specify the "
806 "B<__WALL> or B<__WCLONE> options when waiting for the child with "
807 "B<wait>(2). If no signal is specified, then the parent process is not "
808 "signaled when the child terminates."
812 #: build/C/man2/clone.2:178
814 "I<flags> may also be bitwise-or'ed with zero or more of the following "
815 "constants, in order to specify what is shared between the calling process "
816 "and the child process:"
820 #: build/C/man2/clone.2:178
822 msgid "B<CLONE_CHILD_CLEARTID> (since Linux 2.5.49)"
826 #: build/C/man2/clone.2:188
828 "Erase child thread ID at location I<ctid> in child memory when the child "
829 "exits, and do a wakeup on the futex at that address. The address involved "
830 "may be changed by the B<set_tid_address>(2) system call. This is used by "
831 "threading libraries."
835 #: build/C/man2/clone.2:188
837 msgid "B<CLONE_CHILD_SETTID> (since Linux 2.5.49)"
841 #: build/C/man2/clone.2:193
842 msgid "Store child thread ID at location I<ctid> in child memory."
846 #: build/C/man2/clone.2:193
848 msgid "B<CLONE_FILES> (since Linux 2.0)"
852 #: build/C/man2/clone.2:206
854 "If B<CLONE_FILES> is set, the calling process and the child process share "
855 "the same file descriptor table. Any file descriptor created by the calling "
856 "process or by the child process is also valid in the other process. "
857 "Similarly, if one of the processes closes a file descriptor, or changes its "
858 "associated flags (using the B<fcntl>(2) B<F_SETFD> operation), the other "
859 "process is also affected."
863 #: build/C/man2/clone.2:220
865 "If B<CLONE_FILES> is not set, the child process inherits a copy of all file "
866 "descriptors opened in the calling process at the time of B<clone>(). (The "
867 "duplicated file descriptors in the child refer to the same open file "
868 "descriptions (see B<open>(2)) as the corresponding file descriptors in the "
869 "calling process.) Subsequent operations that open or close file "
870 "descriptors, or change file descriptor flags, performed by either the "
871 "calling process or the child process do not affect the other process."
875 #: build/C/man2/clone.2:220
877 msgid "B<CLONE_FS> (since Linux 2.0)"
881 #: build/C/man2/clone.2:235
883 "If B<CLONE_FS> is set, the caller and the child process share the same "
884 "filesystem information. This includes the root of the filesystem, the "
885 "current working directory, and the umask. Any call to B<chroot>(2), "
886 "B<chdir>(2), or B<umask>(2) performed by the calling process or the child "
887 "process also affects the other process."
891 #: build/C/man2/clone.2:247
893 "If B<CLONE_FS> is not set, the child process works on a copy of the "
894 "filesystem information of the calling process at the time of the B<clone>() "
895 "call. Calls to B<chroot>(2), B<chdir>(2), B<umask>(2) performed later by "
896 "one of the processes do not affect the other process."
900 #: build/C/man2/clone.2:247
902 msgid "B<CLONE_IO> (since Linux 2.6.25)"
906 #: build/C/man2/clone.2:256
908 "If B<CLONE_IO> is set, then the new process shares an I/O context with the "
909 "calling process. If this flag is not set, then (as with B<fork>(2)) the "
910 "new process has its own I/O context."
913 #. The following based on text from Jens Axboe
914 #. the anticipatory and CFQ scheduler
917 #: build/C/man2/clone.2:273
919 "The I/O context is the I/O scope of the disk scheduler (i.e, what the I/O "
920 "scheduler uses to model scheduling of a process's I/O). If processes share "
921 "the same I/O context, they are treated as one by the I/O scheduler. As a "
922 "consequence, they get to share disk time. For some I/O schedulers, if two "
923 "processes share an I/O context, they will be allowed to interleave their "
924 "disk access. If several threads are doing I/O on behalf of the same process "
925 "(B<aio_read>(3), for instance), they should employ B<CLONE_IO> to get better "
930 #: build/C/man2/clone.2:277
932 "If the kernel is not configured with the B<CONFIG_BLOCK> option, this flag "
937 #: build/C/man2/clone.2:277 build/C/man2/unshare.2:96
939 msgid "B<CLONE_NEWIPC> (since Linux 2.6.19)"
943 #: build/C/man2/clone.2:287
945 "If B<CLONE_NEWIPC> is set, then create the process in a new IPC namespace. "
946 "If this flag is not set, then (as with B<fork>(2)), the process is created "
947 "in the same IPC namespace as the calling process. This flag is intended for "
948 "the implementation of containers."
951 #. commit 7eafd7c74c3f2e67c27621b987b28397110d643f
952 #. https://lwn.net/Articles/312232/
954 #: build/C/man2/clone.2:299
956 "An IPC namespace provides an isolated view of System\\ V IPC objects (see "
957 "B<svipc>(7)) and (since Linux 2.6.30) POSIX message queues (see "
958 "B<mq_overview>(7)). The common characteristic of these IPC mechanisms is "
959 "that IPC objects are identified by mechanisms other than filesystem "
964 #: build/C/man2/clone.2:303
966 "Objects created in an IPC namespace are visible to all other processes that "
967 "are members of that namespace, but are not visible to processes in other IPC "
972 #: build/C/man2/clone.2:307
974 "When an IPC namespace is destroyed (i.e., when the last process that is a "
975 "member of the namespace terminates), all IPC objects in the namespace are "
976 "automatically destroyed."
980 #: build/C/man2/clone.2:314
982 "Only a privileged process (B<CAP_SYS_ADMIN>) can employ B<CLONE_NEWIPC>. "
983 "This flag can't be specified in conjunction with B<CLONE_SYSVSEM>."
987 #: build/C/man2/clone.2:317
988 msgid "For further information on IPC namespaces, see B<namespaces>(7)."
992 #: build/C/man2/clone.2:317 build/C/man2/unshare.2:113
994 msgid "B<CLONE_NEWNET> (since Linux 2.6.24)"
998 #: build/C/man2/clone.2:321
1000 "(The implementation of this flag was completed only by about kernel version "
1005 #: build/C/man2/clone.2:330
1007 "If B<CLONE_NEWNET> is set, then create the process in a new network "
1008 "namespace. If this flag is not set, then (as with B<fork>(2)) the process "
1009 "is created in the same network namespace as the calling process. This flag "
1010 "is intended for the implementation of containers."
1013 #. FIXME . Add pointer to veth(4) page when it is eventually completed
1015 #: build/C/man2/clone.2:345
1017 "A network namespace provides an isolated view of the networking stack "
1018 "(network device interfaces, IPv4 and IPv6 protocol stacks, IP routing "
1019 "tables, firewall rules, the I</proc/net> and I</sys/class/net> directory "
1020 "trees, sockets, etc.). A physical network device can live in exactly one "
1021 "network namespace. A virtual network device (\"veth\") pair provides a "
1022 "pipe-like abstraction that can be used to create tunnels between network "
1023 "namespaces, and can be used to create a bridge to a physical network device "
1024 "in another namespace."
1028 #: build/C/man2/clone.2:352
1030 "When a network namespace is freed (i.e., when the last process in the "
1031 "namespace terminates), its physical network devices are moved back to the "
1032 "initial network namespace (not to the parent of the process). For further "
1033 "information on network namespaces, see B<namespaces>(7)."
1037 #: build/C/man2/clone.2:357
1038 msgid "Only a privileged process (B<CAP_SYS_ADMIN>) can employ B<CLONE_NEWNET>."
1042 #: build/C/man2/clone.2:357
1044 msgid "B<CLONE_NEWNS> (since Linux 2.4.19)"
1048 #: build/C/man2/clone.2:367
1050 "If B<CLONE_NEWNS> is set, the cloned child is started in a new mount "
1051 "namespace, initialized with a copy of the namespace of the parent. If "
1052 "B<CLONE_NEWNS> is not set, the child lives in the same mount namespace as "
1057 #: build/C/man2/clone.2:370
1058 msgid "For further information on mount namespaces, see B<namespaces>(7)."
1061 #. See https://lwn.net/Articles/543273/
1063 #: build/C/man2/clone.2:383
1065 "Only a privileged process (B<CAP_SYS_ADMIN>) can employ B<CLONE_NEWNS>. It "
1066 "is not permitted to specify both B<CLONE_NEWNS> and B<CLONE_FS> in the same "
1071 #: build/C/man2/clone.2:383
1073 msgid "B<CLONE_NEWPID> (since Linux 2.6.24)"
1076 #. This explanation draws a lot of details from
1077 #. http://lwn.net/Articles/259217/
1078 #. Authors: Pavel Emelyanov <xemul@openvz.org>
1079 #. and Kir Kolyshkin <kir@openvz.org>
1081 #. The primary kernel commit is 30e49c263e36341b60b735cbef5ca37912549264
1082 #. Author: Pavel Emelyanov <xemul@openvz.org>
1084 #: build/C/man2/clone.2:400
1086 "If B<CLONE_NEWPID> is set, then create the process in a new PID namespace. "
1087 "If this flag is not set, then (as with B<fork>(2)) the process is created "
1088 "in the same PID namespace as the calling process. This flag is intended for "
1089 "the implementation of containers."
1093 #: build/C/man2/clone.2:405
1095 "For further information on PID namespaces, see B<namespaces>(7) and "
1096 "B<pid_namespaces>(7)"
1100 #: build/C/man2/clone.2:414
1102 "Only a privileged process (B<CAP_SYS_ADMIN>) can employ B<CLONE_NEWPID>. "
1103 "This flag can't be specified in conjunction with B<CLONE_THREAD> or "
1108 #: build/C/man2/clone.2:414
1110 msgid "B<CLONE_NEWUSER>"
1114 #: build/C/man2/clone.2:424
1116 "(This flag first became meaningful for B<clone>() in Linux 2.6.23, the "
1117 "current B<clone>() semantics were merged in Linux 3.5, and the final pieces "
1118 "to make the user namespaces completely usable were merged in Linux 3.8.)"
1122 #: build/C/man2/clone.2:431
1124 "If B<CLONE_NEWUSER> is set, then create the process in a new user "
1125 "namespace. If this flag is not set, then (as with B<fork>(2)) the process "
1126 "is created in the same user namespace as the calling process."
1130 #: build/C/man2/clone.2:436
1132 "For further information on user namespaces, see B<namespaces>(7) and "
1133 "B<user_namespaces>(7)"
1136 #. Before Linux 2.6.29, it appears that only CAP_SYS_ADMIN was needed
1138 #: build/C/man2/clone.2:447
1140 "Before Linux 3.8, use of B<CLONE_NEWUSER> required that the caller have "
1141 "three capabilities: B<CAP_SYS_ADMIN>, B<CAP_SETUID>, and B<CAP_SETGID>. "
1142 "Starting with Linux 3.8, no privileges are needed to create a user "
1146 #. commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
1147 #. https://lwn.net/Articles/543273/
1148 #. The fix actually went into 3.9 and into 3.8.3. However, user namespaces
1149 #. were, for practical purposes, unusable in earlier 3.8.x because of the
1150 #. various filesystems that didn't support userns.
1152 #: build/C/man2/clone.2:461
1154 "This flag can't be specified in conjunction with B<CLONE_THREAD> or "
1155 "B<CLONE_PARENT>. For security reasons, B<CLONE_NEWUSER> cannot be specified "
1156 "in conjunction with B<CLONE_FS>."
1160 #: build/C/man2/clone.2:464 build/C/man2/unshare.2:209
1161 msgid "For further information on user namespaces, see B<user_namespaces>(7)."
1165 #: build/C/man2/clone.2:464 build/C/man2/unshare.2:209
1167 msgid "B<CLONE_NEWUTS> (since Linux 2.6.19)"
1171 #: build/C/man2/clone.2:476
1173 "If B<CLONE_NEWUTS> is set, then create the process in a new UTS namespace, "
1174 "whose identifiers are initialized by duplicating the identifiers from the "
1175 "UTS namespace of the calling process. If this flag is not set, then (as "
1176 "with B<fork>(2)) the process is created in the same UTS namespace as the "
1177 "calling process. This flag is intended for the implementation of "
1182 #: build/C/man2/clone.2:487
1184 "A UTS namespace is the set of identifiers returned by B<uname>(2); among "
1185 "these, the domain name and the hostname can be modified by "
1186 "B<setdomainname>(2) and B<sethostname>(2), respectively. Changes made to "
1187 "the identifiers in a UTS namespace are visible to all other processes in the "
1188 "same namespace, but are not visible to processes in other UTS namespaces."
1192 #: build/C/man2/clone.2:492
1193 msgid "Only a privileged process (B<CAP_SYS_ADMIN>) can employ B<CLONE_NEWUTS>."
1197 #: build/C/man2/clone.2:495
1198 msgid "For further information on UTS namespaces, see B<namespaces>(7)."
1202 #: build/C/man2/clone.2:495
1204 msgid "B<CLONE_PARENT> (since Linux 2.3.12)"
1208 #: build/C/man2/clone.2:502
1210 "If B<CLONE_PARENT> is set, then the parent of the new child (as returned by "
1211 "B<getppid>(2)) will be the same as that of the calling process."
1215 #: build/C/man2/clone.2:508
1217 "If B<CLONE_PARENT> is not set, then (as with B<fork>(2)) the child's parent "
1218 "is the calling process."
1222 #: build/C/man2/clone.2:516
1224 "Note that it is the parent process, as returned by B<getppid>(2), which is "
1225 "signaled when the child terminates, so that if B<CLONE_PARENT> is set, then "
1226 "the parent of the calling process, rather than the calling process itself, "
1231 #: build/C/man2/clone.2:516
1233 msgid "B<CLONE_PARENT_SETTID> (since Linux 2.5.49)"
1237 #: build/C/man2/clone.2:524
1239 "Store child thread ID at location I<ptid> in parent and child memory. (In "
1240 "Linux 2.5.32-2.5.48 there was a flag B<CLONE_SETTID> that did this.)"
1244 #: build/C/man2/clone.2:524
1246 msgid "B<CLONE_PID> (obsolete)"
1250 #: build/C/man2/clone.2:535
1252 "If B<CLONE_PID> is set, the child process is created with the same process "
1253 "ID as the calling process. This is good for hacking the system, but "
1254 "otherwise of not much use. Since 2.3.21 this flag can be specified only by "
1255 "the system boot process (PID 0). It disappeared in Linux 2.5.16."
1259 #: build/C/man2/clone.2:535
1261 msgid "B<CLONE_PTRACE> (since Linux 2.2)"
1265 #: build/C/man2/clone.2:542
1267 "If B<CLONE_PTRACE> is specified, and the calling process is being traced, "
1268 "then trace the child also (see B<ptrace>(2))."
1272 #: build/C/man2/clone.2:542
1274 msgid "B<CLONE_SETTLS> (since Linux 2.5.32)"
1278 #: build/C/man2/clone.2:549
1280 "The I<newtls> argument is the new TLS (Thread Local Storage) descriptor. "
1281 "(See B<set_thread_area>(2).)"
1285 #: build/C/man2/clone.2:549
1287 msgid "B<CLONE_SIGHAND> (since Linux 2.0)"
1291 #: build/C/man2/clone.2:565
1293 "If B<CLONE_SIGHAND> is set, the calling process and the child process share "
1294 "the same table of signal handlers. If the calling process or child process "
1295 "calls B<sigaction>(2) to change the behavior associated with a signal, the "
1296 "behavior is changed in the other process as well. However, the calling "
1297 "process and child processes still have distinct signal masks and sets of "
1298 "pending signals. So, one of them may block or unblock some signals using "
1299 "B<sigprocmask>(2) without affecting the other process."
1303 #: build/C/man2/clone.2:576
1305 "If B<CLONE_SIGHAND> is not set, the child process inherits a copy of the "
1306 "signal handlers of the calling process at the time B<clone>() is called. "
1307 "Calls to B<sigaction>(2) performed later by one of the processes have no "
1308 "effect on the other process."
1312 #: build/C/man2/clone.2:584
1314 "Since Linux 2.6.0-test6, I<flags> must also include B<CLONE_VM> if "
1315 "B<CLONE_SIGHAND> is specified"
1319 #: build/C/man2/clone.2:584
1321 msgid "B<CLONE_STOPPED> (since Linux 2.6.0-test2)"
1325 #: build/C/man2/clone.2:593
1327 "If B<CLONE_STOPPED> is set, then the child is initially stopped (as though "
1328 "it was sent a B<SIGSTOP> signal), and must be resumed by sending it a "
1329 "B<SIGCONT> signal."
1332 #. glibc 2.8 removed this defn from bits/sched.h
1334 #: build/C/man2/clone.2:601
1336 "This flag was I<deprecated> from Linux 2.6.25 onward, and was I<removed> "
1337 "altogether in Linux 2.6.38."
1341 #: build/C/man2/clone.2:601
1343 msgid "B<CLONE_SYSVSEM> (since Linux 2.5.10)"
1347 #: build/C/man2/clone.2:619
1349 "If B<CLONE_SYSVSEM> is set, then the child and the calling process share a "
1350 "single list of System V semaphore adjustment (I<semadj>) values (see "
1351 "B<semop>(2)). In this case, the shared list accumulates I<semadj> values "
1352 "across all processes sharing the list, and semaphore adjustments are "
1353 "performed only when the last process that is sharing the list terminates (or "
1354 "ceases sharing the list using B<unshare>(2)). If this flag is not set, then "
1355 "the child has a separate I<semadj> list that is initially empty."
1359 #: build/C/man2/clone.2:619
1361 msgid "B<CLONE_THREAD> (since Linux 2.4.0-test8)"
1365 #: build/C/man2/clone.2:628
1367 "If B<CLONE_THREAD> is set, the child is placed in the same thread group as "
1368 "the calling process. To make the remainder of the discussion of "
1369 "B<CLONE_THREAD> more readable, the term \"thread\" is used to refer to the "
1370 "processes within a thread group."
1374 #: build/C/man2/clone.2:636
1376 "Thread groups were a feature added in Linux 2.4 to support the POSIX threads "
1377 "notion of a set of threads that share a single PID. Internally, this shared "
1378 "PID is the so-called thread group identifier (TGID) for the thread group. "
1379 "Since Linux 2.4, calls to B<getpid>(2) return the TGID of the caller."
1383 #: build/C/man2/clone.2:645
1385 "The threads within a group can be distinguished by their (system-wide) "
1386 "unique thread IDs (TID). A new thread's TID is available as the function "
1387 "result returned to the caller of B<clone>(), and a thread can obtain its own "
1388 "TID using B<gettid>(2)."
1392 #: build/C/man2/clone.2:655
1394 "When a call is made to B<clone>() without specifying B<CLONE_THREAD>, then "
1395 "the resulting thread is placed in a new thread group whose TGID is the same "
1396 "as the thread's TID. This thread is the I<leader> of the new thread group."
1400 #: build/C/man2/clone.2:677
1402 "A new thread created with B<CLONE_THREAD> has the same parent process as the "
1403 "caller of B<clone>() (i.e., like B<CLONE_PARENT>), so that calls to "
1404 "B<getppid>(2) return the same value for all of the threads in a thread "
1405 "group. When a B<CLONE_THREAD> thread terminates, the thread that created it "
1406 "using B<clone>() is not sent a B<SIGCHLD> (or other termination) signal; "
1407 "nor can the status of such a thread be obtained using B<wait>(2). (The "
1408 "thread is said to be I<detached>.)"
1412 #: build/C/man2/clone.2:682
1414 "After all of the threads in a thread group terminate the parent process of "
1415 "the thread group is sent a B<SIGCHLD> (or other termination) signal."
1419 #: build/C/man2/clone.2:687
1421 "If any of the threads in a thread group performs an B<execve>(2), then all "
1422 "threads other than the thread group leader are terminated, and the new "
1423 "program is executed in the thread group leader."
1427 #: build/C/man2/clone.2:693
1429 "If one of the threads in a thread group creates a child using B<fork>(2), "
1430 "then any thread in the group can B<wait>(2) for that child."
1434 #: build/C/man2/clone.2:706
1436 "Since Linux 2.5.35, I<flags> must also include B<CLONE_SIGHAND> if "
1437 "B<CLONE_THREAD> is specified (and note that, since Linux 2.6.0-test6, "
1438 "B<CLONE_SIGHAND> also requires B<CLONE_VM> to be included)."
1442 #: build/C/man2/clone.2:711
1444 "Signals may be sent to a thread group as a whole (i.e., a TGID) using "
1445 "B<kill>(2), or to a specific thread (i.e., TID) using B<tgkill>(2)."
1449 #: build/C/man2/clone.2:716
1451 "Signal dispositions and actions are process-wide: if an unhandled signal is "
1452 "delivered to a thread, then it will affect (terminate, stop, continue, be "
1453 "ignored in) all members of the thread group."
1457 #: build/C/man2/clone.2:729
1459 "Each thread has its own signal mask, as set by B<sigprocmask>(2), but "
1460 "signals can be pending either: for the whole process (i.e., deliverable to "
1461 "any member of the thread group), when sent with B<kill>(2); or for an "
1462 "individual thread, when sent with B<tgkill>(2). A call to B<sigpending>(2) "
1463 "returns a signal set that is the union of the signals pending for the whole "
1464 "process and the signals that are pending for the calling thread."
1468 #: build/C/man2/clone.2:741
1470 "If B<kill>(2) is used to send a signal to a thread group, and the thread "
1471 "group has installed a handler for the signal, then the handler will be "
1472 "invoked in exactly one, arbitrarily selected member of the thread group that "
1473 "has not blocked the signal. If multiple threads in a group are waiting to "
1474 "accept the same signal using B<sigwaitinfo>(2), the kernel will arbitrarily "
1475 "select one of these threads to receive a signal sent using B<kill>(2)."
1479 #: build/C/man2/clone.2:741
1481 msgid "B<CLONE_UNTRACED> (since Linux 2.5.46)"
1485 #: build/C/man2/clone.2:748
1487 "If B<CLONE_UNTRACED> is specified, then a tracing process cannot force "
1488 "B<CLONE_PTRACE> on this child process."
1492 #: build/C/man2/clone.2:748
1494 msgid "B<CLONE_VFORK> (since Linux 2.2)"
1498 #: build/C/man2/clone.2:760
1500 "If B<CLONE_VFORK> is set, the execution of the calling process is suspended "
1501 "until the child releases its virtual memory resources via a call to "
1502 "B<execve>(2) or B<_exit>(2) (as with B<vfork>(2))."
1506 #: build/C/man2/clone.2:766
1508 "If B<CLONE_VFORK> is not set, then both the calling process and the child "
1509 "are schedulable after the call, and an application should not rely on "
1510 "execution occurring in any particular order."
1514 #: build/C/man2/clone.2:766
1516 msgid "B<CLONE_VM> (since Linux 2.0)"
1520 #: build/C/man2/clone.2:779
1522 "If B<CLONE_VM> is set, the calling process and the child process run in the "
1523 "same memory space. In particular, memory writes performed by the calling "
1524 "process or by the child process are also visible in the other process. "
1525 "Moreover, any memory mapping or unmapping performed with B<mmap>(2) or "
1526 "B<munmap>(2) by the child or calling process also affects the other "
1531 #: build/C/man2/clone.2:788
1533 "If B<CLONE_VM> is not set, the child process runs in a separate copy of the "
1534 "memory space of the calling process at the time of B<clone>(). Memory "
1535 "writes or file mappings/unmappings performed by one of the processes do not "
1536 "affect the other, as with B<fork>(2)."
1540 #: build/C/man2/clone.2:788 build/C/man2/sched_setaffinity.2:212
1542 msgid "C library/kernel ABI differences"
1546 #: build/C/man2/clone.2:804
1548 "The raw B<clone>() system call corresponds more closely to B<fork>(2) in "
1549 "that execution in the child continues from the point of the call. As such, "
1550 "the I<fn> and I<arg> arguments of the B<clone>() wrapper function are "
1551 "omitted. Furthermore, the argument order changes. The raw system call "
1552 "interface on x86 and many other architectures is roughly:"
1556 #: build/C/man2/clone.2:810
1559 "B<long clone(unsigned long >I<flags>B<, void *>I<child_stack>B<,>\n"
1560 "B< void *>I<ptid>B<, void *>I<ctid>B<,>\n"
1561 "B< struct pt_regs *>I<regs>B<);>\n"
1565 #: build/C/man2/clone.2:821
1567 "Another difference for the raw system call is that the I<child_stack> "
1568 "argument may be zero, in which case copy-on-write semantics ensure that the "
1569 "child gets separate copies of stack pages when either process modifies the "
1570 "stack. In this case, for correct operation, the B<CLONE_VM> option should "
1575 #: build/C/man2/clone.2:829
1577 "For some architectures, the order of the arguments for the system call "
1578 "differs from that shown above. On the score, microblaze, ARM, ARM 64, "
1579 "PA-RISC, arc, Power PC, xtensa, and MIPS architectures, the order of the "
1580 "fourth and fifth arguments is reversed. On the cris and s390 architectures, "
1581 "the order of the first and second arguments is reversed."
1585 #: build/C/man2/clone.2:829
1587 msgid "blackfin, m68k, and sparc"
1591 #: build/C/man2/clone.2:833
1593 "The argument-passing conventions on blackfin, m68k, and sparc are different "
1594 "from the descriptions above. For details, see the kernel (and glibc) "
1599 #: build/C/man2/clone.2:833
1605 #: build/C/man2/clone.2:835
1606 msgid "On ia64, a different interface is used:"
1610 #: build/C/man2/clone.2:842
1613 "B<int __clone2(int (*>I<fn>B<)(void *), >\n"
1614 "B< void *>I<child_stack_base>B<, size_t >I<stack_size>B<,>\n"
1615 "B< int >I<flags>B<, void *>I<arg>B<, ... >\n"
1616 "B< /* pid_t *>I<ptid>B<, struct user_desc *>I<tls>B<, pid_t "
1617 "*>I<ctid>B< */ );>\n"
1621 #: build/C/man2/clone.2:854
1623 "The prototype shown above is for the glibc wrapper function; the raw system "
1624 "call interface has no I<fn> or I<arg> argument, and changes the order of the "
1625 "arguments so that I<flags> is the first argument, and I<tls> is the last "
1630 #: build/C/man2/clone.2:865
1632 "B<__clone2>() operates in the same way as B<clone>(), except that "
1633 "I<child_stack_base> points to the lowest address of the child's stack area, "
1634 "and I<stack_size> specifies the size of the stack pointed to by "
1635 "I<child_stack_base>."
1639 #: build/C/man2/clone.2:865
1641 msgid "Linux 2.4 and earlier"
1645 #: build/C/man2/clone.2:873
1647 "In Linux 2.4 and earlier, B<clone>() does not take arguments I<ptid>, "
1648 "I<tls>, and I<ctid>."
1651 #. gettid(2) returns current->pid;
1652 #. getpid(2) returns current->tgid;
1654 #: build/C/man2/clone.2:882
1656 "On success, the thread ID of the child process is returned in the caller's "
1657 "thread of execution. On failure, -1 is returned in the caller's context, no "
1658 "child process will be created, and I<errno> will be set appropriately."
1662 #: build/C/man2/clone.2:882 build/C/man2/kcmp.2:170 build/C/man2/sched_get_priority_max.2:107 build/C/man3/sched_getcpu.3:65 build/C/man2/sched_rr_get_interval.2:80 build/C/man2/sched_setaffinity.2:116 build/C/man2/sched_setattr.2:271 build/C/man2/sched_setparam.2:96 build/C/man2/sched_setscheduler.2:145 build/C/man2/sched_yield.2:48 build/C/man2/setns.2:145 build/C/man2/unshare.2:282
1668 #: build/C/man2/clone.2:883
1674 #: build/C/man2/clone.2:887
1675 msgid "Too many processes are already running; see B<fork>(2)."
1679 #: build/C/man2/clone.2:887 build/C/man2/clone.2:894 build/C/man2/clone.2:909 build/C/man2/clone.2:926 build/C/man2/clone.2:934 build/C/man2/clone.2:946 build/C/man2/clone.2:952 build/C/man2/clone.2:962 build/C/man2/clone.2:970 build/C/man2/clone.2:978 build/C/man2/kcmp.2:181 build/C/man2/sched_get_priority_max.2:108 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_setattr.2:276 build/C/man2/sched_setattr.2:300 build/C/man2/sched_setattr.2:323 build/C/man2/sched_setparam.2:97 build/C/man2/sched_setparam.2:104 build/C/man2/sched_setscheduler.2:146 build/C/man2/sched_setscheduler.2:153 build/C/man2/sched_setscheduler.2:158 build/C/man2/setns.2:150 build/C/man2/setns.2:155 build/C/man2/setns.2:159 build/C/man2/setns.2:164 build/C/man2/setns.2:168 build/C/man2/setns.2:175 build/C/man2/unshare.2:283 build/C/man2/unshare.2:287
1685 #: build/C/man2/clone.2:894
1687 "B<CLONE_SIGHAND> was specified, but B<CLONE_VM> was not. (Since Linux "
1694 #. .B CLONE_DETACHED
1698 #. (Since Linux 2.6.0-test6.)
1700 #: build/C/man2/clone.2:909
1702 "B<CLONE_THREAD> was specified, but B<CLONE_SIGHAND> was not. (Since Linux "
1706 #. commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
1708 #: build/C/man2/clone.2:918
1709 msgid "Both B<CLONE_FS> and B<CLONE_NEWNS> were specified in I<flags>."
1713 #: build/C/man2/clone.2:918
1715 msgid "B<EINVAL> (since Linux 3.9)"
1719 #: build/C/man2/clone.2:926
1720 msgid "Both B<CLONE_NEWUSER> and B<CLONE_FS> were specified in I<flags>."
1724 #: build/C/man2/clone.2:934
1725 msgid "Both B<CLONE_NEWIPC> and B<CLONE_SYSVSEM> were specified in I<flags>."
1729 #: build/C/man2/clone.2:946
1731 "One (or both) of B<CLONE_NEWPID> or B<CLONE_NEWUSER> and one (or both) of "
1732 "B<CLONE_THREAD> or B<CLONE_PARENT> were specified in I<flags>."
1736 #: build/C/man2/clone.2:952
1737 msgid "Returned by B<clone>() when a zero value is specified for I<child_stack>."
1741 #: build/C/man2/clone.2:962
1743 "B<CLONE_NEWIPC> was specified in I<flags>, but the kernel was not configured "
1744 "with the B<CONFIG_SYSVIPC> and B<CONFIG_IPC_NS> options."
1748 #: build/C/man2/clone.2:970
1750 "B<CLONE_NEWNET> was specified in I<flags>, but the kernel was not configured "
1751 "with the B<CONFIG_NET_NS> option."
1755 #: build/C/man2/clone.2:978
1757 "B<CLONE_NEWPID> was specified in I<flags>, but the kernel was not configured "
1758 "with the B<CONFIG_PID_NS> option."
1762 #: build/C/man2/clone.2:986
1764 "B<CLONE_NEWUTS> was specified in I<flags>, but the kernel was not configured "
1765 "with the B<CONFIG_UTS> option."
1769 #: build/C/man2/clone.2:986 build/C/man2/setns.2:179 build/C/man2/unshare.2:296
1775 #: build/C/man2/clone.2:991
1777 "Cannot allocate sufficient memory to allocate a task structure for the "
1778 "child, or to copy those parts of the caller's context that need to be "
1783 #: build/C/man2/clone.2:991 build/C/man2/clone.2:1000 build/C/man2/clone.2:1004 build/C/man2/kcmp.2:185 build/C/man2/sched_setaffinity.2:135 build/C/man2/sched_setattr.2:339 build/C/man2/sched_setattr.2:342 build/C/man2/sched_setparam.2:109 build/C/man2/sched_setscheduler.2:164 build/C/man2/setns.2:182 build/C/man2/unshare.2:300 build/C/man2/unshare.2:303
1789 #: build/C/man2/clone.2:1000
1791 "B<CLONE_NEWIPC>, B<CLONE_NEWNET>, B<CLONE_NEWNS>, B<CLONE_NEWPID>, or "
1792 "B<CLONE_NEWUTS> was specified by an unprivileged process (process without "
1793 "B<CAP_SYS_ADMIN>)."
1797 #: build/C/man2/clone.2:1004
1798 msgid "B<CLONE_PID> was specified by a process other than process 0."
1802 #: build/C/man2/clone.2:1012 build/C/man2/unshare.2:311
1804 "B<CLONE_NEWUSER> was specified in I<flags>, but either the effective user ID "
1805 "or the effective group ID of the caller does not have a mapping in the "
1806 "parent namespace (see B<user_namespaces>(7))."
1810 #: build/C/man2/clone.2:1012 build/C/man2/unshare.2:311
1812 msgid "B<EPERM> (since Linux 3.9)"
1815 #. commit 3151527ee007b73a0ebd296010f1c0454a919c7d
1816 #. FIXME What is the rationale for this restriction?
1818 #: build/C/man2/clone.2:1022 build/C/man2/unshare.2:321
1820 "B<CLONE_NEWUSER> was specified in I<flags> and the caller is in a chroot "
1821 "environment (i.e., the caller's root directory does not match the root "
1822 "directory of the mount namespace in which it resides)."
1826 #: build/C/man2/clone.2:1022 build/C/man2/unshare.2:321
1828 msgid "B<EUSERS> (since Linux 3.11)"
1832 #: build/C/man2/clone.2:1031 build/C/man2/unshare.2:330
1834 "B<CLONE_NEWUSER> was specified in I<flags>, and the call would cause the "
1835 "limit on the number of nested user namespaces to be exceeded. See "
1836 "B<user_namespaces>(7)."
1840 #: build/C/man2/clone.2:1038
1842 "There is no entry for B<clone>() in libc5. glibc2 provides B<clone>() as "
1843 "described in this manual page."
1847 #: build/C/man2/clone.2:1042
1849 "B<clone>() is Linux-specific and should not be used in programs intended to "
1854 #: build/C/man2/clone.2:1052
1856 "In the kernel 2.4.x series, B<CLONE_THREAD> generally does not make the "
1857 "parent of the new thread the same as the parent of the calling process. "
1858 "However, for kernel versions 2.4.7 to 2.4.18 the B<CLONE_THREAD> flag "
1859 "implied the B<CLONE_PARENT> flag (as in kernel 2.6)."
1863 #: build/C/man2/clone.2:1062
1865 "For a while there was B<CLONE_DETACHED> (introduced in 2.5.32): parent wants "
1866 "no child-exit signal. In 2.6.2 the need to give this together with "
1867 "B<CLONE_THREAD> disappeared. This flag is still defined, but has no effect."
1871 #: build/C/man2/clone.2:1067
1873 "On i386, B<clone>() should not be called through vsyscall, but directly "
1874 "through I<int $0x80>."
1878 #: build/C/man2/clone.2:1098
1880 "Versions of the GNU C library that include the NPTL threading library "
1881 "contain a wrapper function for B<getpid>(2) that performs caching of PIDs. "
1882 "This caching relies on support in the glibc wrapper for B<clone>(), but as "
1883 "currently implemented, the cache may not be up to date in some "
1884 "circumstances. In particular, if a signal is delivered to the child "
1885 "immediately after the B<clone>() call, then a call to B<getpid>(2) in a "
1886 "handler for the signal may return the PID of the calling process (\"the "
1887 "parent\"), if the clone wrapper has not yet had a chance to update the PID "
1888 "cache in the child. (This discussion ignores the case where the child was "
1889 "created using B<CLONE_THREAD>, when B<getpid>(2) I<should> return the same "
1890 "value in the child and in the process that called B<clone>(), since the "
1891 "caller and the child are in the same thread group. The stale-cache problem "
1892 "also does not occur if the I<flags> argument includes B<CLONE_VM>.) To get "
1893 "the truth, it may be necessary to use code such as the following:"
1897 #: build/C/man2/clone.2:1101
1899 msgid " #include E<lt>syscall.hE<gt>\n"
1903 #: build/C/man2/clone.2:1103
1905 msgid " pid_t mypid;\n"
1909 #: build/C/man2/clone.2:1105
1911 msgid " mypid = syscall(SYS_getpid);\n"
1915 #: build/C/man2/clone.2:1119
1917 "The following program demonstrates the use of B<clone>() to create a child "
1918 "process that executes in a separate UTS namespace. The child changes the "
1919 "hostname in its UTS namespace. Both parent and child then display the "
1920 "system hostname, making it possible to see that the hostname differs in the "
1921 "UTS namespaces of the parent and child. For an example of the use of this "
1922 "program, see B<setns>(2)."
1926 #: build/C/man2/clone.2:1119 build/C/man2/setns.2:255 build/C/man2/unshare.2:396
1928 msgid "Program source"
1932 #: build/C/man2/clone.2:1129
1935 "#define _GNU_SOURCE\n"
1936 "#include E<lt>sys/wait.hE<gt>\n"
1937 "#include E<lt>sys/utsname.hE<gt>\n"
1938 "#include E<lt>sched.hE<gt>\n"
1939 "#include E<lt>string.hE<gt>\n"
1940 "#include E<lt>stdio.hE<gt>\n"
1941 "#include E<lt>stdlib.hE<gt>\n"
1942 "#include E<lt>unistd.hE<gt>\n"
1946 #: build/C/man2/clone.2:1132 build/C/man2/setns.2:266 build/C/man2/unshare.2:415
1949 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\e\n"
1954 #: build/C/man2/clone.2:1137
1957 "static int /* Start function for cloned child */\n"
1958 "childFunc(void *arg)\n"
1960 " struct utsname uts;\n"
1964 #: build/C/man2/clone.2:1139
1966 msgid " /* Change hostname in UTS namespace of child */\n"
1970 #: build/C/man2/clone.2:1142
1973 " if (sethostname(arg, strlen(arg)) == -1)\n"
1974 " errExit(\"sethostname\");\n"
1978 #: build/C/man2/clone.2:1144
1980 msgid " /* Retrieve and display hostname */\n"
1984 #: build/C/man2/clone.2:1148
1987 " if (uname(&uts) == -1)\n"
1988 " errExit(\"uname\");\n"
1989 " printf(\"uts.nodename in child: %s\\en\", uts.nodename);\n"
1993 #: build/C/man2/clone.2:1152
1996 " /* Keep the namespace open for a while, by sleeping.\n"
1997 " This allows some experimentation--for example, another\n"
1998 " process might join the namespace. */\n"
2002 #: build/C/man2/clone.2:1154
2004 msgid " sleep(200);\n"
2008 #: build/C/man2/clone.2:1157
2011 " return 0; /* Child terminates now */\n"
2016 #: build/C/man2/clone.2:1159
2018 msgid "#define STACK_SIZE (1024 * 1024) /* Stack size for cloned child */\n"
2022 #: build/C/man2/clone.2:1167
2026 "main(int argc, char *argv[])\n"
2028 " char *stack; /* Start of stack buffer */\n"
2029 " char *stackTop; /* End of stack buffer */\n"
2031 " struct utsname uts;\n"
2035 #: build/C/man2/clone.2:1172
2038 " if (argc E<lt> 2) {\n"
2039 " fprintf(stderr, \"Usage: %s E<lt>child-hostnameE<gt>\\en\", "
2041 " exit(EXIT_SUCCESS);\n"
2046 #: build/C/man2/clone.2:1174
2048 msgid " /* Allocate stack for child */\n"
2052 #: build/C/man2/clone.2:1179
2055 " stack = malloc(STACK_SIZE);\n"
2056 " if (stack == NULL)\n"
2057 " errExit(\"malloc\");\n"
2058 " stackTop = stack + STACK_SIZE; /* Assume stack grows downward */\n"
2062 #: build/C/man2/clone.2:1182
2065 " /* Create child that has its own UTS namespace;\n"
2066 " child commences execution in childFunc() */\n"
2070 #: build/C/man2/clone.2:1187
2073 " pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);\n"
2075 " errExit(\"clone\");\n"
2076 " printf(\"clone() returned %ld\\en\", (long) pid);\n"
2080 #: build/C/man2/clone.2:1189
2082 msgid " /* Parent falls through to here */\n"
2086 #: build/C/man2/clone.2:1191
2088 msgid " sleep(1); /* Give child time to change its hostname */\n"
2092 #: build/C/man2/clone.2:1194
2095 " /* Display hostname in parent\\(aqs UTS namespace. This will be\n"
2096 " different from hostname in child\\(aqs UTS namespace. */\n"
2100 #: build/C/man2/clone.2:1198
2103 " if (uname(&uts) == -1)\n"
2104 " errExit(\"uname\");\n"
2105 " printf(\"uts.nodename in parent: %s\\en\", uts.nodename);\n"
2109 #: build/C/man2/clone.2:1202
2112 " if (waitpid(pid, NULL, 0) == -1) /* Wait for child */\n"
2113 " errExit(\"waitpid\");\n"
2114 " printf(\"child has terminated\\en\");\n"
2118 #: build/C/man2/clone.2:1205
2121 " exit(EXIT_SUCCESS);\n"
2126 #: build/C/man2/clone.2:1221
2128 "B<fork>(2), B<futex>(2), B<getpid>(2), B<gettid>(2), B<kcmp>(2), "
2129 "B<set_thread_area>(2), B<set_tid_address>(2), B<setns>(2), B<tkill>(2), "
2130 "B<unshare>(2), B<wait>(2), B<capabilities>(7), B<namespaces>(7), "
2135 #: build/C/man2/kcmp.2:28
2141 #: build/C/man2/kcmp.2:28
2147 #: build/C/man2/kcmp.2:31
2148 msgid "kcmp - compare two processes to determine if they share a kernel resource"
2152 #: build/C/man2/kcmp.2:34
2154 msgid "B<#include E<lt>linux/kcmp.hE<gt>>\n"
2158 #: build/C/man2/kcmp.2:37
2161 "B<int kcmp(pid_t >I<pid1>B<, pid_t >I<pid2>B<, int >I<type>B<,>\n"
2162 "B< unsigned long >I<idx1>B<, unsigned long >I<idx2>B<);>\n"
2166 #: build/C/man2/kcmp.2:41
2167 msgid "I<Note>: There is no glibc wrapper for this system call; see NOTES."
2171 #: build/C/man2/kcmp.2:50
2173 "The B<kcmp>() system call can be used to check whether the two processes "
2174 "identified by I<pid1> and I<pid2> share a kernel resource such as virtual "
2175 "memory, file descriptors, and so on."
2179 #: build/C/man2/kcmp.2:55
2181 "The I<type> argument specifies which resource is to be compared in the two "
2182 "processes. It has one of the following values:"
2186 #: build/C/man2/kcmp.2:55
2188 msgid "B<KCMP_FILE>"
2192 #: build/C/man2/kcmp.2:67
2194 "Check whether a file descriptor I<idx1> in the process I<pid1> refers to the "
2195 "same open file description (see B<open>(2)) as file descriptor I<idx2> in "
2196 "the process I<pid2>."
2200 #: build/C/man2/kcmp.2:67
2202 msgid "B<KCMP_FILES>"
2206 #: build/C/man2/kcmp.2:75
2208 "Check whether the process share the same set of open file descriptors. The "
2209 "arguments I<idx1> and I<idx2> are ignored."
2213 #: build/C/man2/kcmp.2:75
2219 #: build/C/man2/kcmp.2:84
2221 "Check whether the processes share the same filesystem information (i.e., "
2222 "file mode creation mask, working directory, and filesystem root). The "
2223 "arguments I<idx1> and I<idx2> are ignored."
2227 #: build/C/man2/kcmp.2:84
2233 #: build/C/man2/kcmp.2:92
2235 "Check whether the processes share I/O context. The arguments I<idx1> and "
2236 "I<idx2> are ignored."
2240 #: build/C/man2/kcmp.2:92
2242 msgid "B<KCMP_SIGHAND>"
2246 #: build/C/man2/kcmp.2:100
2248 "Check whether the processes share the same table of signal dispositions. "
2249 "The arguments I<idx1> and I<idx2> are ignored."
2253 #: build/C/man2/kcmp.2:100
2255 msgid "B<KCMP_SYSVSEM>"
2259 #: build/C/man2/kcmp.2:109
2261 "Check whether the processes share the same list of System\\ V semaphore undo "
2262 "operations. The arguments I<idx1> and I<idx2> are ignored."
2266 #: build/C/man2/kcmp.2:109
2272 #: build/C/man2/kcmp.2:117
2274 "Check whether the processes share the same address space. The arguments "
2275 "I<idx1> and I<idx2> are ignored."
2279 #: build/C/man2/kcmp.2:127
2281 "Note the B<kcmp>() is not protected against false positives which may occur "
2282 "if tasks are running. One should stop tasks by sending B<SIGSTOP> (see "
2283 "B<signal>(7)) prior to inspection with this system call to obtain "
2284 "meaningful results."
2288 #: build/C/man2/kcmp.2:133
2290 "The return value of a successful call to B<kcmp>() is simply the result of "
2291 "arithmetic comparison of kernel pointers (when the kernel compares "
2292 "resources, it uses their memory addresses)."
2296 #: build/C/man2/kcmp.2:141
2298 "The easiest way to explain is to consider an example. Suppose that I<v1> "
2299 "and I<v2> are the addresses of appropriate resources, then the return value "
2300 "is one of the following:"
2304 #: build/C/man2/kcmp.2:142
2310 #: build/C/man2/kcmp.2:147
2312 "I<v1> is equal to I<v2>; in other words, the two processes share the "
2317 #: build/C/man2/kcmp.2:147
2323 #: build/C/man2/kcmp.2:151
2324 msgid "I<v1> is less than I<v2>."
2328 #: build/C/man2/kcmp.2:151
2334 #: build/C/man2/kcmp.2:155
2335 msgid "I<v1> is greater than I<v2>."
2339 #: build/C/man2/kcmp.2:155
2345 #: build/C/man2/kcmp.2:160
2346 msgid "I<v1> is not equal to I<v2>, but ordering information is unavailable."
2350 #: build/C/man2/kcmp.2:165
2351 msgid "On error, -1 is returned, and I<errno> is set appropriately."
2355 #: build/C/man2/kcmp.2:170
2357 "B<kcmp>() was designed to return values suitable for sorting. This is "
2358 "particularly handy if one needs to compare a large number of file "
2363 #: build/C/man2/kcmp.2:171 build/C/man2/setns.2:146
2369 #: build/C/man2/kcmp.2:181
2370 msgid "I<type> is B<KCMP_FILE> and I<fd1> or I<fd2> is not an open file descriptor."
2374 #: build/C/man2/kcmp.2:185
2375 msgid "I<type> is invalid."
2379 #: build/C/man2/kcmp.2:191
2381 "Insufficient permission to inspect process resources. The B<CAP_SYS_PTRACE> "
2382 "capability is required to inspect processes that you do not own."
2386 #: build/C/man2/kcmp.2:191 build/C/man2/sched_rr_get_interval.2:90 build/C/man2/sched_setaffinity.2:145 build/C/man2/sched_setattr.2:284 build/C/man2/sched_setparam.2:116 build/C/man2/sched_setscheduler.2:167
2392 #: build/C/man2/kcmp.2:198
2393 msgid "Process I<pid1> or I<pid2> does not exist."
2397 #: build/C/man2/kcmp.2:202
2398 msgid "The B<kcmp>() system call first appeared in Linux 3.5."
2402 #: build/C/man2/kcmp.2:205
2404 "B<kcmp>() is Linux-specific and should not be used in programs intended to "
2409 #: build/C/man2/kcmp.2:208
2411 "Glibc does not provide a wrapper for this system call; call it using "
2416 #: build/C/man2/kcmp.2:217
2418 "This system call is available only if the kernel was configured with "
2419 "B<CONFIG_CHECKPOINT_RESTORE>. The main use of the system call is for the "
2420 "checkpoint/restore in user space (CRIU) feature. The alternative to this "
2421 "system call would have been to expose suitable process information via the "
2422 "B<proc>(5) filesystem; this was deemed to be unsuitable for security "
2427 #: build/C/man2/kcmp.2:222
2429 "See B<clone>(2) for some background information on the shared resources "
2430 "referred to on this page."
2434 #: build/C/man2/kcmp.2:225
2435 msgid "B<clone>(2), B<unshare>(2)"
2439 #: build/C/man2/sched_get_priority_max.2:29
2441 msgid "SCHED_GET_PRIORITY_MAX"
2445 #: build/C/man2/sched_get_priority_max.2:29
2451 #: build/C/man2/sched_get_priority_max.2:32
2452 msgid "sched_get_priority_max, sched_get_priority_min - get static priority range"
2456 #: 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
2457 msgid "B<#include E<lt>sched.hE<gt>>"
2461 #: build/C/man2/sched_get_priority_max.2:36
2462 msgid "B<int sched_get_priority_max(int >I<policy>B<);>"
2466 #: build/C/man2/sched_get_priority_max.2:38
2467 msgid "B<int sched_get_priority_min(int >I<policy>B<);>"
2471 #: build/C/man2/sched_get_priority_max.2:59
2473 "B<sched_get_priority_max>() returns the maximum priority value that can be "
2474 "used with the scheduling algorithm identified by I<policy>. "
2475 "B<sched_get_priority_min>() returns the minimum priority value that can be "
2476 "used with the scheduling algorithm identified by I<policy>. Supported "
2477 "I<policy> values are B<SCHED_FIFO>, B<SCHED_RR>, B<SCHED_OTHER>, "
2478 "B<SCHED_BATCH>, B<SCHED_IDLE>, and B<SCHED_DEADLINE>. Further details about "
2479 "these policies can be found in B<sched>(7)."
2483 #: build/C/man2/sched_get_priority_max.2:68
2485 "Processes with numerically higher priority values are scheduled before "
2486 "processes with numerically lower priority values. Thus, the value returned "
2487 "by B<sched_get_priority_max>() will be greater than the value returned by "
2488 "B<sched_get_priority_min>()."
2492 #: build/C/man2/sched_get_priority_max.2:76
2494 "Linux allows the static priority range 1 to 99 for the B<SCHED_FIFO> and "
2495 "B<SCHED_RR> policies, and the priority 0 for the remaining policies. "
2496 "Scheduling priority ranges for the various policies are not alterable."
2500 #: build/C/man2/sched_get_priority_max.2:88
2502 "The range of scheduling priorities may vary on other POSIX systems, thus it "
2503 "is a good idea for portable applications to use a virtual priority range and "
2504 "map it to the interval given by B<sched_get_priority_max>() and "
2505 "B<sched_get_priority_min>(). POSIX.1-2001 requires a spread of at least 32 "
2506 "between the maximum and the minimum values for B<SCHED_FIFO> and "
2511 #: build/C/man2/sched_get_priority_max.2:97
2513 "POSIX systems on which B<sched_get_priority_max>() and "
2514 "B<sched_get_priority_min>() are available define "
2515 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2519 #: build/C/man2/sched_get_priority_max.2:107
2521 "On success, B<sched_get_priority_max>() and B<sched_get_priority_min>() "
2522 "return the maximum/minimum priority value for the named scheduling policy. "
2523 "On error, -1 is returned, and I<errno> is set appropriately."
2527 #: build/C/man2/sched_get_priority_max.2:113
2528 msgid "The argument I<policy> does not identify a defined scheduling policy."
2532 #: build/C/man2/sched_get_priority_max.2:115 build/C/man2/sched_rr_get_interval.2:96 build/C/man2/sched_setparam.2:121 build/C/man2/sched_yield.2:54
2533 msgid "POSIX.1-2001."
2537 #: build/C/man2/sched_get_priority_max.2:125
2539 "B<sched_getaffinity>(2), B<sched_getparam>(2), B<sched_getscheduler>(2), "
2540 "B<sched_setaffinity>(2), B<sched_setparam>(2), B<sched_setscheduler>(2), "
2545 #: build/C/man3/sched_getcpu.3:26
2547 msgid "SCHED_GETCPU"
2551 #: build/C/man3/sched_getcpu.3:26
2557 #: build/C/man3/sched_getcpu.3:29
2558 msgid "sched_getcpu - determine CPU on which the calling thread is running"
2562 #: build/C/man3/sched_getcpu.3:34
2564 msgid "B<int sched_getcpu(void);>\n"
2568 #: build/C/man3/sched_getcpu.3:39 build/C/man2/unshare.2:33
2569 msgid "Feature Test Macro Requirements for glibc (see B<feature_test_macros>(7)):"
2573 #: build/C/man3/sched_getcpu.3:42
2574 msgid "B<sched_getcpu>():"
2578 #: build/C/man3/sched_getcpu.3:58
2580 "B<sched_getcpu>() returns the number of the CPU on which the calling thread "
2581 "is currently executing."
2585 #: build/C/man3/sched_getcpu.3:65
2587 "On success, B<sched_getcpu>() returns a nonnegative CPU number. On error, "
2588 "-1 is returned and I<errno> is set to indicate the error."
2592 #: build/C/man3/sched_getcpu.3:66 build/C/man2/sched_rr_get_interval.2:87
2598 #: build/C/man3/sched_getcpu.3:70
2599 msgid "This kernel does not implement B<getcpu>(2)."
2603 #: build/C/man3/sched_getcpu.3:72
2604 msgid "This function is available since glibc 2.6."
2608 #: build/C/man3/sched_getcpu.3:72
2614 #: build/C/man3/sched_getcpu.3:73
2616 msgid "Multithreading (see pthreads(7))"
2620 #: build/C/man3/sched_getcpu.3:77
2621 msgid "The B<sched_getcpu>() function is thread-safe."
2625 #: build/C/man3/sched_getcpu.3:80
2626 msgid "B<sched_getcpu>() is glibc-specific."
2630 #: build/C/man3/sched_getcpu.3:82
2635 #: build/C/man3/sched_getcpu.3:86
2637 msgid "cpu = sched_getcpu();\n"
2641 #: build/C/man3/sched_getcpu.3:92
2642 msgid "is equivalent to the following B<getcpu>(2) call:"
2646 #: build/C/man3/sched_getcpu.3:98
2650 "s = getcpu(&c, NULL, NULL);\n"
2651 "cpu = (s == -1) ? s : c;\n"
2655 #: build/C/man3/sched_getcpu.3:103
2656 msgid "B<getcpu>(2), B<sched>(7)"
2660 #: build/C/man2/sched_rr_get_interval.2:29
2662 msgid "SCHED_RR_GET_INTERVAL"
2666 #: build/C/man2/sched_rr_get_interval.2:29 build/C/man2/sched_yield.2:29
2672 #: build/C/man2/sched_rr_get_interval.2:32
2673 msgid "sched_rr_get_interval - get the SCHED_RR interval for the named process"
2677 #: build/C/man2/sched_rr_get_interval.2:36
2678 msgid "B<int sched_rr_get_interval(pid_t >I<pid>B<, struct timespec * >I<tp>B<);>"
2682 #: build/C/man2/sched_rr_get_interval.2:47
2684 "B<sched_rr_get_interval>() writes into the I<timespec> structure pointed to "
2685 "by I<tp> the round-robin time quantum for the process identified by I<pid>. "
2686 "The specified process should be running under the B<SCHED_RR> scheduling "
2691 #: build/C/man2/sched_rr_get_interval.2:51
2692 msgid "The I<timespec> structure has the following form:"
2696 #: build/C/man2/sched_rr_get_interval.2:58
2699 "struct timespec {\n"
2700 " time_t tv_sec; /* seconds */\n"
2701 " long tv_nsec; /* nanoseconds */\n"
2705 #. FIXME . On Linux, sched_rr_get_interval()
2706 #. returns the timeslice for SCHED_OTHER processes -- this timeslice
2707 #. is influenced by the nice value.
2708 #. For SCHED_FIFO processes, this always returns 0.
2710 #. The round-robin time quantum value is not alterable under Linux
2713 #: build/C/man2/sched_rr_get_interval.2:73
2715 "If I<pid> is zero, the time quantum for the calling process is written into "
2720 #: build/C/man2/sched_rr_get_interval.2:80
2722 "On success, B<sched_rr_get_interval>() returns 0. On error, -1 is "
2723 "returned, and I<errno> is set appropriately."
2727 #: build/C/man2/sched_rr_get_interval.2:81 build/C/man2/sched_setaffinity.2:117
2733 #: build/C/man2/sched_rr_get_interval.2:84
2734 msgid "Problem with copying information to user space."
2738 #: build/C/man2/sched_rr_get_interval.2:87
2739 msgid "Invalid pid."
2743 #: build/C/man2/sched_rr_get_interval.2:90
2744 msgid "The system call is not yet implemented (only on rather old kernels)."
2748 #: build/C/man2/sched_rr_get_interval.2:94
2749 msgid "Could not find a process with the ID I<pid>."
2753 #: build/C/man2/sched_rr_get_interval.2:103
2755 "POSIX systems on which B<sched_rr_get_interval>() is available define "
2756 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
2760 #: build/C/man2/sched_rr_get_interval.2:103
2765 #. commit a4ec24b48ddef1e93f7578be53270f0b95ad666c
2767 #: build/C/man2/sched_rr_get_interval.2:117
2769 "POSIX does not specify any mechanism for controlling the size of the "
2770 "round-robin time quantum. Older Linux kernels provide a (nonportable) "
2771 "method of doing this. The quantum can be controlled by adjusting the "
2772 "process's nice value (see B<setpriority>(2)). Assigning a negative (i.e., "
2773 "high) nice value results in a longer quantum; assigning a positive (i.e., "
2774 "low) nice value results in a shorter quantum. The default quantum is 0.1 "
2775 "seconds; the degree to which changing the nice value affects the quantum has "
2776 "varied somewhat across kernel versions. This method of adjusting the "
2777 "quantum was removed starting with Linux 2.6.24."
2780 #. commit ce0dbbbb30aee6a835511d5be446462388ba9eee
2782 #. As of Linux 1.3.81
2783 #. .BR sched_rr_get_interval ()
2784 #. returns with error
2785 #. ENOSYS, because SCHED_RR has not yet been fully implemented and tested
2788 #: build/C/man2/sched_rr_get_interval.2:132
2790 "Linux 3.9 added a new mechanism for adjusting (and viewing) the B<SCHED_RR> "
2791 "quantum: the I</proc/sys/kernel/sched_rr_timeslice_ms> file exposes the "
2792 "quantum as a millisecond value, whose default is 100. Writing 0 to this "
2793 "file resets the quantum to the default value."
2797 #: build/C/man2/sched_rr_get_interval.2:134 build/C/man2/sched_yield.2:81
2802 #: build/C/man2/sched_setaffinity.2:34
2804 msgid "SCHED_SETAFFINITY"
2808 #: build/C/man2/sched_setaffinity.2:34
2814 #: build/C/man2/sched_setaffinity.2:38
2816 "sched_setaffinity, sched_getaffinity - set and get a thread's CPU affinity "
2821 #: build/C/man2/sched_setaffinity.2:45
2824 "B<int sched_setaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2825 "B< const cpu_set_t *>I<mask>B<);>\n"
2829 #: build/C/man2/sched_setaffinity.2:48
2832 "B<int sched_getaffinity(pid_t >I<pid>B<, size_t >I<cpusetsize>B<,>\n"
2833 "B< cpu_set_t *>I<mask>B<);>\n"
2837 #: build/C/man2/sched_setaffinity.2:63
2839 "A thread's CPU affinity mask determines the set of CPUs on which it is "
2840 "eligible to run. On a multiprocessor system, setting the CPU affinity mask "
2841 "can be used to obtain performance benefits. For example, by dedicating one "
2842 "CPU to a particular thread (i.e., setting the affinity mask of that thread "
2843 "to specify a single CPU, and setting the affinity mask of all other threads "
2844 "to exclude that CPU), it is possible to ensure maximum execution speed for "
2845 "that thread. Restricting a thread to run on a single CPU also avoids the "
2846 "performance cost caused by the cache invalidation that occurs when a thread "
2847 "ceases to execute on one CPU and then recommences execution on a different "
2852 #: build/C/man2/sched_setaffinity.2:70
2854 "A CPU affinity mask is represented by the I<cpu_set_t> structure, a \"CPU "
2855 "set\", pointed to by I<mask>. A set of macros for manipulating CPU sets is "
2856 "described in B<CPU_SET>(3)."
2860 #: build/C/man2/sched_setaffinity.2:85
2862 "B<sched_setaffinity>() sets the CPU affinity mask of the thread whose ID is "
2863 "I<pid> to the value specified by I<mask>. If I<pid> is zero, then the "
2864 "calling thread is used. The argument I<cpusetsize> is the length (in bytes) "
2865 "of the data pointed to by I<mask>. Normally this argument would be "
2866 "specified as I<sizeof(cpu_set_t)>."
2870 #: build/C/man2/sched_setaffinity.2:92
2872 "If the thread specified by I<pid> is not currently running on one of the "
2873 "CPUs specified in I<mask>, then that thread is migrated to one of the CPUs "
2874 "specified in I<mask>."
2878 #: build/C/man2/sched_setaffinity.2:107
2880 "B<sched_getaffinity>() writes the affinity mask of the thread whose ID is "
2881 "I<pid> into the I<cpu_set_t> structure pointed to by I<mask>. The "
2882 "I<cpusetsize> argument specifies the size (in bytes) of I<mask>. If I<pid> "
2883 "is zero, then the mask of the calling thread is returned."
2887 #: build/C/man2/sched_setaffinity.2:116
2889 "On success, B<sched_setaffinity>() and B<sched_getaffinity>() return 0. "
2890 "On error, -1 is returned, and I<errno> is set appropriately."
2894 #: build/C/man2/sched_setaffinity.2:120
2895 msgid "A supplied memory address was invalid."
2899 #: build/C/man2/sched_setaffinity.2:128
2901 "The affinity bit mask I<mask> contains no processors that are currently "
2902 "physically on the system and permitted to the thread according to any "
2903 "restrictions that may be imposed by the \"cpuset\" mechanism described in "
2908 #: build/C/man2/sched_setaffinity.2:135
2910 "(B<sched_getaffinity>() and, in kernels before 2.6.9, "
2911 "B<sched_setaffinity>()) I<cpusetsize> is smaller than the size of the "
2912 "affinity mask used by the kernel."
2916 #: build/C/man2/sched_setaffinity.2:145
2918 "(B<sched_setaffinity>()) The calling thread does not have appropriate "
2919 "privileges. The caller needs an effective user ID equal to the real user ID "
2920 "or effective user ID of the thread identified by I<pid>, or it must possess "
2921 "the B<CAP_SYS_NICE> capability."
2925 #: build/C/man2/sched_setaffinity.2:148 build/C/man2/sched_setattr.2:289 build/C/man2/sched_setscheduler.2:170
2926 msgid "The thread whose ID is I<pid> could not be found."
2930 #: build/C/man2/sched_setaffinity.2:159
2932 "The CPU affinity system calls were introduced in Linux kernel 2.5.8. The "
2933 "system call wrappers were introduced in glibc 2.3. Initially, the glibc "
2934 "interfaces included a I<cpusetsize> argument, typed as I<unsigned int>. In "
2935 "glibc 2.3.3, the I<cpusetsize> argument was removed, but was then restored "
2936 "in glibc 2.3.4, with type I<size_t>."
2940 #: build/C/man2/sched_setaffinity.2:161
2941 msgid "These system calls are Linux-specific."
2945 #: build/C/man2/sched_setaffinity.2:174
2947 "After a call to B<sched_setaffinity>(), the set of CPUs on which the thread "
2948 "will actually run is the intersection of the set specified in the I<mask> "
2949 "argument and the set of CPUs actually present on the system. The system may "
2950 "further restrict the set of CPUs on which the thread runs if the \"cpuset\" "
2951 "mechanism described in B<cpuset>(7) is being used. These restrictions on "
2952 "the actual set of CPUs on which the thread will run are silently imposed by "
2957 #: build/C/man2/sched_setaffinity.2:186
2959 "There are various ways of determining the number of CPUs available on the "
2960 "system, including: inspecting the contents of I</proc/cpuinfo>; using "
2961 "B<syconf>(3) to obtain the values of the B<_SC_NPROCESSORS_CONF> and "
2962 "B<_SC_NPROCESSORS_ONLN> parameters; and inspecting the list CPU directories "
2963 "under I</sys/devices/system/cpu/>."
2967 #: build/C/man2/sched_setaffinity.2:189
2968 msgid "B<sched>(7) has a description of the Linux scheduling scheme."
2972 #: build/C/man2/sched_setaffinity.2:206
2974 "The affinity mask is a per-thread attribute that can be adjusted "
2975 "independently for each of the threads in a thread group. The value returned "
2976 "from a call to B<gettid>(2) can be passed in the argument I<pid>. "
2977 "Specifying I<pid> as 0 will set the attribute for the calling thread, and "
2978 "passing the value returned from a call to B<getpid>(2) will set the "
2979 "attribute for the main thread of the thread group. (If you are using the "
2980 "POSIX threads API, then use B<pthread_setaffinity_np>(3) instead of "
2981 "B<sched_setaffinity>().)"
2985 #: build/C/man2/sched_setaffinity.2:212
2987 "A child created via B<fork>(2) inherits its parent's CPU affinity mask. "
2988 "The affinity mask is preserved across an B<execve>(2)."
2992 #: build/C/man2/sched_setaffinity.2:226
2994 "This manual page describes the glibc interface for the CPU affinity calls. "
2995 "The actual system call interface is slightly different, with the I<mask> "
2996 "being typed as I<unsigned long\\ *>, reflecting the fact that the underlying "
2997 "implementation of CPU sets is a simple bit mask. On success, the raw "
2998 "B<sched_getaffinity>() system call returns the size (in bytes) of the "
2999 "I<cpumask_t> data type that is used internally by the kernel to represent "
3000 "the CPU set bit mask."
3004 #: build/C/man2/sched_setaffinity.2:248
3006 "B<lscpu>(1), B<nproc>(1), B<taskset>(1), B<clone>(2), B<getcpu>(2), "
3007 "B<getpriority>(2), B<gettid>(2), B<nice>(2), B<sched_get_priority_max>(2), "
3008 "B<sched_get_priority_min>(2), B<sched_getscheduler>(2), "
3009 "B<sched_setscheduler>(2), B<setpriority>(2), B<CPU_SET>(3), "
3010 "B<pthread_setaffinity_np>(3), B<sched_getcpu>(3), B<capabilities>(7), "
3011 "B<cpuset>(7), B<sched>(7)"
3015 #: build/C/man2/sched_setattr.2:26
3017 msgid "SCHED_SETATTR"
3021 #: build/C/man2/sched_setattr.2:26 build/C/man2/sched_setscheduler.2:26 build/C/man7/sched.7:32
3027 #: build/C/man2/sched_setattr.2:30
3028 msgid "sched_setattr, sched_getattr - set and get scheduling policy and attributes"
3032 #: build/C/man2/sched_setattr.2:36
3035 "B<int sched_setattr(pid_t >I<pid>B<, const struct sched_attr *>I<attr>B<,>\n"
3036 "B< unsigned int >I<flags>B<);>\n"
3040 #: build/C/man2/sched_setattr.2:39
3043 "B<int sched_getattr(pid_t >I<pid>B<, const struct sched_attr *>I<attr>B<,>\n"
3044 "B< unsigned int >I<size>B<, unsigned int >I<flags>B<);>\n"
3048 #: build/C/man2/sched_setattr.2:42
3050 msgid "sched_setattr()"
3054 #: build/C/man2/sched_setattr.2:52
3056 "The B<sched_setattr>() system call sets the scheduling policy and "
3057 "associated attributes for the thread whose ID is specified in I<pid>. If "
3058 "I<pid> equals zero, the scheduling policy and attributes of the calling "
3059 "thread will be set."
3063 #: build/C/man2/sched_setattr.2:56 build/C/man2/sched_setscheduler.2:73
3065 "Currently, Linux supports the following \"normal\" (i.e., non-real-time) "
3066 "scheduling policies as values that may be specified in I<policy>:"
3070 #: build/C/man2/sched_setattr.2:56 build/C/man2/sched_setscheduler.2:73
3072 msgid "B<SCHED_OTHER>"
3075 #. In the 2.6 kernel sources, SCHED_OTHER is actually called
3078 #: build/C/man2/sched_setattr.2:61 build/C/man2/sched_setscheduler.2:78
3079 msgid "the standard round-robin time-sharing policy;"
3083 #: build/C/man2/sched_setattr.2:61 build/C/man2/sched_setscheduler.2:78
3085 msgid "B<SCHED_BATCH>"
3089 #: build/C/man2/sched_setattr.2:64 build/C/man2/sched_setscheduler.2:81
3090 msgid "for \"batch\" style execution of processes; and"
3094 #: build/C/man2/sched_setattr.2:64 build/C/man2/sched_setscheduler.2:81
3096 msgid "B<SCHED_IDLE>"
3100 #: build/C/man2/sched_setattr.2:69 build/C/man2/sched_setscheduler.2:86
3101 msgid "for running I<very> low priority background jobs."
3105 #: build/C/man2/sched_setattr.2:78 build/C/man2/sched_setscheduler.2:99
3107 "Various \"real-time\" policies are also supported, for special time-critical "
3108 "applications that need precise control over the way in which runnable "
3109 "threads are selected for execution. For the rules governing when a process "
3110 "may use these policies, see B<sched>(7). The real-time policies that may be "
3111 "specified in I<policy> are:"
3115 #: build/C/man2/sched_setattr.2:78 build/C/man2/sched_setscheduler.2:99
3117 msgid "B<SCHED_FIFO>"
3121 #: build/C/man2/sched_setattr.2:81 build/C/man2/sched_setscheduler.2:102
3122 msgid "a first-in, first-out policy; and"
3126 #: build/C/man2/sched_setattr.2:81 build/C/man2/sched_setscheduler.2:102
3132 #: build/C/man2/sched_setattr.2:84 build/C/man2/sched_setscheduler.2:105
3133 msgid "a round-robin policy."
3137 #: build/C/man2/sched_setattr.2:86
3138 msgid "Linux also provides the following policy:"
3142 #: build/C/man2/sched_setattr.2:86
3144 msgid "B<SCHED_DEADLINE>"
3148 #: build/C/man2/sched_setattr.2:91
3149 msgid "a deadline scheduling policy; see B<sched>(7) for details."
3153 #: build/C/man2/sched_setattr.2:97
3155 "The I<attr> argument is a pointer to a structure that defines the new "
3156 "scheduling policy and attributes for the specified thread. This structure "
3157 "has the following form:"
3161 #: build/C/man2/sched_setattr.2:113
3164 "struct sched_attr {\n"
3165 " u32 size; /* Size of this structure */\n"
3166 " u32 sched_policy; /* Policy (SCHED_*) */\n"
3167 " u64 sched_flags; /* Flags */\n"
3168 " s32 sched_nice; /* Nice value (SCHED_OTHER,\n"
3169 " SCHED_BATCH) */\n"
3170 " u32 sched_priority; /* Static priority (SCHED_FIFO,\n"
3172 " /* Remaining fields are for SCHED_DEADLINE */\n"
3173 " u64 sched_runtime;\n"
3174 " u64 sched_deadline;\n"
3175 " u64 sched_period;\n"
3180 #: build/C/man2/sched_setattr.2:117
3181 msgid "The fields of this structure are as follows:"
3185 #: build/C/man2/sched_setattr.2:117
3191 #: build/C/man2/sched_setattr.2:132
3193 "This field should be set to the size of the structure in bytes, as in "
3194 "I<sizeof(struct sched_attr)>. If the provided structure is smaller than the "
3195 "kernel structure, any additional fields are assumed to be '0'. If the "
3196 "provided structure is larger than the kernel structure, the kernel verifies "
3197 "that all additional fields are 0; if they are not, B<sched_setattr>() fails "
3198 "with the error B<E2BIG> and updates I<size> to contain the size of the "
3203 #: build/C/man2/sched_setattr.2:146
3205 "The above behavior when the size of the user-space I<sched_attr> structure "
3206 "does not match the size of the kernel structure allows for future "
3207 "extensibility of the interface. Malformed applications that pass oversize "
3208 "structures won't break in the future if the size of the kernel I<sched_attr> "
3209 "structure is increased. In the future, it could also allow applications "
3210 "that know about a larger user-space I<sched_attr> structure to determine "
3211 "whether they are running on an older kernel that does not support the larger "
3216 #: build/C/man2/sched_setattr.2:146
3218 msgid "I<sched_policy>"
3222 #: build/C/man2/sched_setattr.2:151
3224 "This field specifies the scheduling policy, as one of the B<SCHED_*> values "
3229 #: build/C/man2/sched_setattr.2:151
3231 msgid "I<sched_flags>"
3235 #: build/C/man2/sched_setattr.2:162
3237 "This field contains flags controlling scheduling behavior. Only one such "
3238 "flag is currently defined: B<SCHED_FLAG_RESET_ON_FORK>. As a result of "
3239 "including this flag, children created by B<fork>(2) do not inherit "
3240 "privileged scheduling policies. See B<sched>(7) for details."
3244 #: build/C/man2/sched_setattr.2:162
3246 msgid "I<sched_nice>"
3250 #: build/C/man2/sched_setattr.2:173
3252 "This field specifies the nice value to be set when specifying "
3253 "I<sched_policy> as B<SCHED_OTHER> or B<SCHED_BATCH>. The nice value is a "
3254 "number in the range -20 (high priority) to +19 (low priority); see "
3255 "B<setpriority>(2)."
3259 #: build/C/man2/sched_setattr.2:173
3261 msgid "I<sched_priority>"
3265 #: build/C/man2/sched_setattr.2:186
3267 "This field specifies the static priority to be set when specifying "
3268 "I<sched_policy> as B<SCHED_FIFO> or B<SCHED_RR>. The allowed range of "
3269 "priorities for these policies can be determined using "
3270 "B<sched_get_priority_min>(2) and B<sched_get_priority_max>(2). For other "
3271 "policies, this field must be specified as 0."
3275 #: build/C/man2/sched_setattr.2:186
3277 msgid "I<sched_runtime>"
3281 #: build/C/man2/sched_setattr.2:195
3283 "This field specifies the \"Runtime\" parameter for deadline scheduling. The "
3284 "value is expressed in nanoseconds. This field, and the next two fields, are "
3285 "used only for B<SCHED_DEADLINE> scheduling; for further details, see "
3290 #: build/C/man2/sched_setattr.2:195
3292 msgid "I<sched_deadline>"
3296 #: build/C/man2/sched_setattr.2:199
3298 "This field specifies the \"Deadline\" parameter for deadline scheduling. "
3299 "The value is expressed in nanoseconds."
3303 #: build/C/man2/sched_setattr.2:199
3305 msgid "I<sched_period>"
3309 #: build/C/man2/sched_setattr.2:203
3311 "This field specifies the \"Period\" parameter for deadline scheduling. The "
3312 "value is expressed in nanoseconds."
3316 #: build/C/man2/sched_setattr.2:210 build/C/man2/sched_setattr.2:262
3318 "The I<flags> argument is provided to allow for future extensions to the "
3319 "interface; in the current implementation it must be specified as 0."
3323 #: build/C/man2/sched_setattr.2:210
3325 msgid "sched_getattr()"
3329 #: build/C/man2/sched_setattr.2:221
3331 "The B<sched_getattr>() system call fetches the scheduling policy and the "
3332 "associated attributes for the thread whose ID is specified in I<pid>. If "
3333 "I<pid> equals zero, the scheduling policy and attributes of the calling "
3334 "thread will be retrieved."
3338 #: build/C/man2/sched_setattr.2:231
3340 "The I<size> argument should be set to the size of the I<sched_attr> "
3341 "structure as known to user space. The value must be at least as large as "
3342 "the size of the initially published I<sched_attr> structure, or the call "
3343 "fails with the error B<EINVAL>."
3347 #: build/C/man2/sched_setattr.2:241
3349 "The retrieved scheduling attributes are placed in the fields of the "
3350 "I<sched_attr> structure pointed to by I<attr>. The kernel sets I<attr.size> "
3351 "to the size of its I<sched_attr> structure."
3355 #: build/C/man2/sched_setattr.2:257
3357 "If the caller-provided I<attr> buffer is larger than the kernel's "
3358 "I<sched_attr> structure, the additional bytes in the user-space structure "
3359 "are not touched. If the caller-provided structure is smaller than the "
3360 "kernel I<sched_attr> structure and the kernel needs to return values outside "
3361 "the provided space, B<sched_getattr>() fails with the error B<E2BIG>. As "
3362 "with B<sched_setattr>(), these semantics allow for future extensibility of "
3367 #: build/C/man2/sched_setattr.2:271
3369 "On success, B<sched_setattr>() and B<sched_getattr>() return 0. On error, "
3370 "-1 is returned, and I<errno> is set to indicate the cause of the error."
3374 #: build/C/man2/sched_setattr.2:276
3376 "B<sched_getattr>() and B<sched_setattr>() can both fail for the following "
3381 #: build/C/man2/sched_setattr.2:284
3382 msgid "I<attr> is NULL; or I<pid> is negative; or I<flags> is not zero."
3386 #: build/C/man2/sched_setattr.2:293
3387 msgid "In addition, B<sched_getattr>() can fail for the following reasons:"
3391 #: build/C/man2/sched_setattr.2:293 build/C/man2/sched_setattr.2:310
3397 #: build/C/man2/sched_setattr.2:300
3398 msgid "The buffer specified by I<size> and I<attr> is too small."
3402 #: build/C/man2/sched_setattr.2:306
3404 "I<size> is invalid; that is, it is smaller than the initial version of the "
3405 "I<sched_attr> structure (48 bytes) or larger than the system page size."
3409 #: build/C/man2/sched_setattr.2:310
3410 msgid "In addition, B<sched_setattr>() can fail for the following reasons:"
3414 #: build/C/man2/sched_setattr.2:318
3416 "The buffer specified by I<size> and I<attr> is larger than the kernel "
3417 "structure, and one or more of the excess bytes is nonzero."
3421 #: build/C/man2/sched_setattr.2:318
3427 #: build/C/man2/sched_setattr.2:323
3428 msgid "B<SCHED_DEADLINE> admission control failure, see B<sched>(7)."
3432 #: build/C/man2/sched_setattr.2:339
3434 "I<attr.sched_policy> is not one of the recognized policies; "
3435 "I<attr.sched_flags> contains a flag other than B<SCHED_FLAG_RESET_ON_FORK>; "
3436 "or I<attr.sched_priority> is invalid; or I<attr.sched_policy> is "
3437 "B<SCHED_DEADLINE> and the deadline scheduling parameters in I<attr> are "
3442 #: build/C/man2/sched_setattr.2:342
3443 msgid "The caller does not have appropriate privileges."
3447 #: build/C/man2/sched_setattr.2:348
3449 "The caller's CPU affinity mask does not include all CPUs in the system (see "
3450 "B<sched_setaffinity>(2))."
3453 #. FIXME . Add glibc version
3455 #: build/C/man2/sched_setattr.2:351
3456 msgid "These system calls first appeared in Linux 3.14."
3460 #: build/C/man2/sched_setattr.2:353
3461 msgid "These system calls are nonstandard Linux extensions."
3465 #: build/C/man2/sched_setattr.2:369
3467 "B<sched_setattr>() provides a superset of the functionality of "
3468 "B<sched_setscheduler>(2), B<sched_setparam>(2), B<nice>(2), and (other than "
3469 "the ability to set the priority of all processes belonging to a specified "
3470 "user or all processes in a specified group) B<setpriority>(2). "
3471 "Analogously, B<sched_getattr>() provides a superset of the functionality of "
3472 "B<sched_getscheduler>(2), B<sched_getparam>(2), and (partially) "
3473 "B<getpriority>(2)."
3476 #. FIXME . patch sent to Peter Zijlstra
3477 #. In Linux versions up to up 3.15,
3478 #. FIXME . patch from Peter Zijlstra pending
3479 #. .BR sched_setattr ()
3480 #. allowed a negative
3481 #. .I attr.sched_policy
3484 #: build/C/man2/sched_setattr.2:385
3486 "In Linux versions up to 3.15, B<sched_settattr>() failed with the error "
3487 "B<EFAULT> instead of B<E2BIG> for the case described in ERRORS."
3491 #: build/C/man2/sched_setattr.2:407
3493 "B<chrt>(1), B<nice>(2), B<sched_get_priority_max>(2), "
3494 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), "
3495 "B<sched_getscheduler>(2), B<sched_getparam>(2), B<sched_rr_get_interval>(2), "
3496 "B<sched_setaffinity>(2), B<sched_setscheduler>(2), B<sched_setparam>(2), "
3497 "B<sched_yield>(2), B<setpriority>(2), B<pthread_getschedparam>(3), "
3498 "B<pthread_setschedparam>(3), B<pthread_setschedprio>(3), B<capabilities>(7), "
3499 "B<cpuset>(7), B<sched>(7)"
3503 #: build/C/man2/sched_setparam.2:30
3505 msgid "SCHED_SETPARAM"
3509 #: build/C/man2/sched_setparam.2:30
3515 #: build/C/man2/sched_setparam.2:33
3516 msgid "sched_setparam, sched_getparam - set and get scheduling parameters"
3520 #: build/C/man2/sched_setparam.2:38
3523 "B<int sched_setparam(pid_t >I<pid>B<, const struct sched_param "
3528 #: build/C/man2/sched_setparam.2:40
3530 msgid "B<int sched_getparam(pid_t >I<pid>B<, struct sched_param *>I<param>B<);>\n"
3534 #: build/C/man2/sched_setparam.2:46
3537 "B<struct sched_param {\n"
3539 " int >I<sched_priority>B<;\n"
3545 #: build/C/man2/sched_setparam.2:60
3547 "B<sched_setparam>() sets the scheduling parameters associated with the "
3548 "scheduling policy for the process identified by I<pid>. If I<pid> is zero, "
3549 "then the parameters of the calling process are set. The interpretation of "
3550 "the argument I<param> depends on the scheduling policy of the process "
3551 "identified by I<pid>. See B<sched>(7) for a description of the scheduling "
3552 "policies supported under Linux."
3556 #: build/C/man2/sched_setparam.2:66
3558 "B<sched_getparam>() retrieves the scheduling parameters for the process "
3559 "identified by I<pid>. If I<pid> is zero, then the parameters of the calling "
3560 "process are retrieved."
3564 #: build/C/man2/sched_setparam.2:75
3566 "B<sched_setparam>() checks the validity of I<param> for the scheduling "
3567 "policy of the thread. The value I<param-E<gt>sched_priority> must lie "
3568 "within the range given by B<sched_get_priority_min>(2) and "
3569 "B<sched_get_priority_max>(2)."
3573 #: build/C/man2/sched_setparam.2:79
3575 "For a discussion of the privileges and resource limits related to scheduling "
3576 "priority and policy, see B<sched>(7)."
3580 #: build/C/man2/sched_setparam.2:87
3582 "POSIX systems on which B<sched_setparam>() and B<sched_getparam>() are "
3583 "available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3587 #: build/C/man2/sched_setparam.2:96
3589 "On success, B<sched_setparam>() and B<sched_getparam>() return 0. On "
3590 "error, -1 is returned, and I<errno> is set appropriately."
3594 #: build/C/man2/sched_setparam.2:104
3595 msgid "Invalid arguments: I<param> is NULL or I<pid> is negative"
3599 #: build/C/man2/sched_setparam.2:109
3601 "(B<sched_setparam>()) The argument I<param> does not make sense for the "
3602 "current scheduling policy."
3606 #: build/C/man2/sched_setparam.2:116
3608 "(B<sched_setparam>()) The calling process does not have appropriate "
3609 "privileges (Linux: does not have the B<CAP_SYS_NICE> capability)."
3613 #: build/C/man2/sched_setparam.2:119
3614 msgid "The process whose ID is I<pid> could not be found."
3618 #: build/C/man2/sched_setparam.2:127
3620 "Scheduling parameters are in fact per-thread attributes on Linux; see "
3625 #: build/C/man2/sched_setparam.2:142
3627 "B<getpriority>(2), B<nice>(2), B<sched_get_priority_max>(2), "
3628 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), "
3629 "B<sched_getscheduler>(2), B<sched_setaffinity>(2), B<sched_setscheduler>(2), "
3630 "B<sched_setattr>(2), B<setpriority>(2), B<capabilities>(7), B<sched>(7)"
3634 #: build/C/man2/sched_setscheduler.2:26
3636 msgid "SCHED_SETSCHEDULER"
3640 #: build/C/man2/sched_setscheduler.2:30
3642 "sched_setscheduler, sched_getscheduler - set and get scheduling "
3647 #: build/C/man2/sched_setscheduler.2:35
3649 msgid "B<int sched_setscheduler(pid_t >I<pid>B<, int >I<policy>B<,>\n"
3653 #: build/C/man2/sched_setscheduler.2:37
3655 msgid "B< const struct sched_param *>I<param>B<);>\n"
3659 #: build/C/man2/sched_setscheduler.2:39
3661 msgid "B<int sched_getscheduler(pid_t >I<pid>B<);>\n"
3665 #: build/C/man2/sched_setscheduler.2:49
3667 "The B<sched_setscheduler>() system call sets both the scheduling policy and "
3668 "parameters for the thread whose ID is specified in I<pid>. If I<pid> equals "
3669 "zero, the scheduling policy and parameters of the calling thread will be "
3674 #: build/C/man2/sched_setscheduler.2:53
3676 "The scheduling parameters are specified in the I<param> argument, which is a "
3677 "pointer to a structure of the following form:"
3681 #: build/C/man2/sched_setscheduler.2:61
3684 "struct sched_param {\n"
3686 " int sched_priority;\n"
3692 #: build/C/man2/sched_setscheduler.2:69
3694 "In the current implementation, the structure contains only one field, "
3695 "I<sched_priority>. The interpretation of I<param> depends on the selected "
3700 #: build/C/man2/sched_setscheduler.2:90
3701 msgid "For each of the above policies, I<param-E<gt>sched_priority> must be 0."
3705 #: build/C/man2/sched_setscheduler.2:116
3707 "For each of the above policies, I<param-E<gt>sched_priority> specifies a "
3708 "scheduling priority for the thread. This is a number in the range returned "
3709 "by calling B<sched_get_priority_min>(2) and B<sched_get_priority_max>(2) "
3710 "with the specified I<policy>. On Linux, these system calls return, "
3711 "respectively, 1 and 99."
3715 #: build/C/man2/sched_setscheduler.2:129
3717 "Since Linux 2.6.32, the B<SCHED_RESET_ON_FORK> flag can be ORed in I<policy> "
3718 "when calling B<sched_setscheduler>(). As a result of including this flag, "
3719 "children created by B<fork>(2) do not inherit privileged scheduling "
3720 "policies. See B<sched>(7) for details."
3724 #: build/C/man2/sched_setscheduler.2:135
3726 "B<sched_getscheduler>() returns the current scheduling policy of the thread "
3727 "identified by I<pid>. If I<pid> equals zero, the policy of the calling "
3728 "thread will be retrieved."
3732 #: build/C/man2/sched_setscheduler.2:145
3734 "On success, B<sched_setscheduler>() returns zero. On success, "
3735 "B<sched_getscheduler>() returns the policy for the thread (a nonnegative "
3736 "integer). On error, both calls return -1, and I<errno> is set "
3741 #: build/C/man2/sched_setscheduler.2:153
3742 msgid "Invalid arguments: I<pid> is negative or I<param> is NULL."
3746 #: build/C/man2/sched_setscheduler.2:158
3747 msgid "(B<sched_setscheduler>()) I<policy> is not one of the recognized policies."
3751 #: build/C/man2/sched_setscheduler.2:164
3753 "(B<sched_setscheduler>()) I<param> does not make sense for the specified "
3758 #: build/C/man2/sched_setscheduler.2:167
3759 msgid "The calling thread does not have appropriate privileges."
3763 #: build/C/man2/sched_setscheduler.2:173
3765 "POSIX.1-2001 (but see BUGS below). The B<SCHED_BATCH> and B<SCHED_IDLE> "
3766 "policies are Linux-specific."
3770 #: build/C/man2/sched_setscheduler.2:177
3772 "Further details of the semantics of all of the above \"normal\" and "
3773 "\"real-time\" scheduling policies can be found in B<sched>(7)."
3777 #: build/C/man2/sched_setscheduler.2:185
3779 "POSIX systems on which B<sched_setscheduler>() and B<sched_getscheduler>() "
3780 "are available define B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3784 #: build/C/man2/sched_setscheduler.2:193
3786 "POSIX.1 does not detail the permissions that an unprivileged thread requires "
3787 "in order to call B<sched_setscheduler>(), and details vary across systems. "
3788 "For example, the Solaris 7 manual page says that the real or effective user "
3789 "ID of the caller must match the real user ID or the save set-user-ID of the "
3794 #: build/C/man2/sched_setscheduler.2:214
3796 "The scheduling policy and parameters are in fact per-thread attributes on "
3797 "Linux. The value returned from a call to B<gettid>(2) can be passed in the "
3798 "argument I<pid>. Specifying I<pid> as 0 will operate on the attributes of "
3799 "the calling thread, and passing the value returned from a call to "
3800 "B<getpid>(2) will operate on the attributes of the main thread of the "
3801 "thread group. (If you are using the POSIX threads API, then use "
3802 "B<pthread_setschedparam>(3), B<pthread_getschedparam>(3), and "
3803 "B<pthread_setschedprio>(3), instead of the B<sched_*>(2) system calls.)"
3807 #: build/C/man2/sched_setscheduler.2:222
3809 "POSIX says that on success, B<sched_setscheduler>() should return the "
3810 "previous scheduling policy. Linux B<sched_setscheduler>() does not conform "
3811 "to this requirement, since it always returns 0 on success."
3815 #: build/C/man2/sched_setscheduler.2:241
3817 "B<chrt>(1), B<nice>(2), B<sched_get_priority_max>(2), "
3818 "B<sched_get_priority_min>(2), B<sched_getaffinity>(2), B<sched_getattr>(2), "
3819 "B<sched_getparam>(2), B<sched_rr_get_interval>(2), B<sched_setaffinity>(2), "
3820 "B<sched_setattr>(2), B<sched_setparam>(2), B<sched_yield>(2), "
3821 "B<setpriority>(2), B<capabilities>(7), B<cpuset>(7), B<sched>(7)"
3825 #: build/C/man2/sched_yield.2:29
3831 #: build/C/man2/sched_yield.2:32
3832 msgid "sched_yield - yield the processor"
3836 #: build/C/man2/sched_yield.2:36
3837 msgid "B<int sched_yield(void);>"
3841 #: build/C/man2/sched_yield.2:41
3843 "B<sched_yield>() causes the calling thread to relinquish the CPU. The "
3844 "thread is moved to the end of the queue for its static priority and a new "
3845 "thread gets to run."
3849 #: build/C/man2/sched_yield.2:48
3851 "On success, B<sched_yield>() returns 0. On error, -1 is returned, and "
3852 "I<errno> is set appropriately."
3856 #: build/C/man2/sched_yield.2:52
3857 msgid "In the Linux implementation, B<sched_yield>() always succeeds."
3861 #: build/C/man2/sched_yield.2:59
3863 "If the calling thread is the only thread in the highest priority list at "
3864 "that time, it will continue to run after a call to B<sched_yield>()."
3868 #: build/C/man2/sched_yield.2:66
3870 "POSIX systems on which B<sched_yield>() is available define "
3871 "B<_POSIX_PRIORITY_SCHEDULING> in I<E<lt>unistd.hE<gt>>."
3875 #: build/C/man2/sched_yield.2:79
3877 "Strategic calls to B<sched_yield>() can improve performance by giving other "
3878 "threads or processes a chance to run when (heavily) contended resources "
3879 "(e.g., mutexes) have been released by the caller. Avoid calling "
3880 "B<sched_yield>() unnecessarily or inappropriately (e.g., when resources "
3881 "needed by other schedulable threads are still held by the caller), since "
3882 "doing so will result in unnecessary context switches, which will degrade "
3883 "system performance."
3887 #: build/C/man7/sched.7:32
3893 #: build/C/man7/sched.7:35
3894 msgid "sched - overview of scheduling APIs"
3898 #: build/C/man7/sched.7:36
3904 #: build/C/man7/sched.7:38
3905 msgid "The Linux scheduling APIs are as follows:"
3909 #: build/C/man7/sched.7:38
3911 msgid "B<sched_setscheduler>(2)"
3915 #: build/C/man7/sched.7:41
3916 msgid "Set the scheduling policy and parameters of a specified thread."
3920 #: build/C/man7/sched.7:41
3922 msgid "B<sched_getscheduler>(2)"
3926 #: build/C/man7/sched.7:44
3927 msgid "Return the scheduling policy of a specified thread."
3931 #: build/C/man7/sched.7:44
3933 msgid "B<sched_setparam>(2)"
3937 #: build/C/man7/sched.7:47
3938 msgid "Set the scheduling parameters of a specified thread."
3942 #: build/C/man7/sched.7:47
3944 msgid "B<sched_getparam>(2)"
3948 #: build/C/man7/sched.7:50
3949 msgid "Fetch the scheduling parameters of a specified thread."
3953 #: build/C/man7/sched.7:50
3955 msgid "B<sched_get_priority_max>(2)"
3959 #: build/C/man7/sched.7:53
3960 msgid "Return the minimum priority available in a specified scheduling policy."
3964 #: build/C/man7/sched.7:53
3966 msgid "B<sched_get_priority_min>(2)"
3970 #: build/C/man7/sched.7:56
3971 msgid "Return the maximum priority available in a specified scheduling policy."
3975 #: build/C/man7/sched.7:56
3977 msgid "B<sched_rr_get_interval>(2)"
3981 #: build/C/man7/sched.7:60
3983 "Fetch the quantum used for threads that are scheduled under the "
3984 "\"round-robin\" scheduling policy."
3988 #: build/C/man7/sched.7:60
3990 msgid "B<sched_yield>(2)"
3994 #: build/C/man7/sched.7:64
3996 "Cause the caller to relinquish the CPU, so that some other thread be "
4001 #: build/C/man7/sched.7:64
4003 msgid "B<sched_setaffinity>(2)"
4007 #: build/C/man7/sched.7:68
4008 msgid "(Linux-specific) Set the CPU affinity of a specified thread."
4012 #: build/C/man7/sched.7:68
4014 msgid "B<sched_getaffinity>(2)"
4018 #: build/C/man7/sched.7:72
4019 msgid "(Linux-specific) Get the CPU affinity of a specified thread."
4023 #: build/C/man7/sched.7:72
4025 msgid "B<sched_setattr>(2)"
4029 #: build/C/man7/sched.7:79
4031 "Set the scheduling policy and parameters of a specified thread. This "
4032 "(Linux-specific) system call provides a superset of the functionality of "
4033 "B<sched_setscheduler>(2) and B<sched_setparam>(2)."
4037 #: build/C/man7/sched.7:79
4039 msgid "B<sched_getattr>(2)"
4043 #: build/C/man7/sched.7:87
4045 "Fetch the scheduling policy and parameters of a specified thread. This "
4046 "(Linux-specific) system call provides a superset of the functionality of "
4047 "B<sched_getscheduler>(2) and B<sched_getparam>(2)."
4051 #: build/C/man7/sched.7:87
4053 msgid "Scheduling policies"
4057 #: build/C/man7/sched.7:95
4059 "The scheduler is the kernel component that decides which runnable thread "
4060 "will be executed by the CPU next. Each thread has an associated scheduling "
4061 "policy and a I<static> scheduling priority, I<sched_priority>. The "
4062 "scheduler makes its decisions based on knowledge of the scheduling policy "
4063 "and static priority of all threads on the system."
4067 #: build/C/man7/sched.7:100
4069 "For threads scheduled under one of the normal scheduling policies "
4070 "(B<SCHED_OTHER>, B<SCHED_IDLE>, B<SCHED_BATCH>), I<sched_priority> is not "
4071 "used in scheduling decisions (it must be specified as 0)."
4075 #: build/C/man7/sched.7:114
4077 "Processes scheduled under one of the real-time policies (B<SCHED_FIFO>, "
4078 "B<SCHED_RR>) have a I<sched_priority> value in the range 1 (low) to 99 "
4079 "(high). (As the numbers imply, real-time threads always have higher "
4080 "priority than normal threads.) Note well: POSIX.1-2001 requires an "
4081 "implementation to support only a minimum 32 distinct priority levels for the "
4082 "real-time policies, and some systems supply just this minimum. Portable "
4083 "programs should use B<sched_get_priority_min>(2) and "
4084 "B<sched_get_priority_max>(2) to find the range of priorities supported for "
4085 "a particular policy."
4089 #: build/C/man7/sched.7:120
4091 "Conceptually, the scheduler maintains a list of runnable threads for each "
4092 "possible I<sched_priority> value. In order to determine which thread runs "
4093 "next, the scheduler looks for the nonempty list with the highest static "
4094 "priority and selects the thread at the head of this list."
4098 #: build/C/man7/sched.7:124
4100 "A thread's scheduling policy determines where it will be inserted into the "
4101 "list of threads with equal static priority and how it will move inside this "
4106 #: build/C/man7/sched.7:132
4108 "All scheduling is preemptive: if a thread with a higher static priority "
4109 "becomes ready to run, the currently running thread will be preempted and "
4110 "returned to the wait list for its static priority level. The scheduling "
4111 "policy determines the ordering only within the list of runnable threads with "
4112 "equal static priority."
4116 #: build/C/man7/sched.7:132
4118 msgid "SCHED_FIFO: First in-first out scheduling"
4122 #: build/C/man7/sched.7:141
4124 "B<SCHED_FIFO> can be used only with static priorities higher than 0, which "
4125 "means that when a B<SCHED_FIFO> threads becomes runnable, it will always "
4126 "immediately preempt any currently running B<SCHED_OTHER>, B<SCHED_BATCH>, or "
4127 "B<SCHED_IDLE> thread. B<SCHED_FIFO> is a simple scheduling algorithm "
4128 "without time slicing. For threads scheduled under the B<SCHED_FIFO> policy, "
4129 "the following rules apply:"
4133 #: build/C/man7/sched.7:141 build/C/man7/sched.7:146 build/C/man7/sched.7:149 build/C/man7/sched.7:164 build/C/man7/sched.7:412 build/C/man7/sched.7:421 build/C/man7/sched.7:444 build/C/man7/sched.7:452 build/C/man7/sched.7:491 build/C/man7/sched.7:499 build/C/man7/sched.7:504 build/C/man7/sched.7:509
4139 #: build/C/man7/sched.7:146
4141 "A B<SCHED_FIFO> thread that has been preempted by another thread of higher "
4142 "priority will stay at the head of the list for its priority and will resume "
4143 "execution as soon as all threads of higher priority are blocked again."
4147 #: build/C/man7/sched.7:149
4149 "When a B<SCHED_FIFO> thread becomes runnable, it will be inserted at the end "
4150 "of the list for its priority."
4153 #. In 2.2.x and 2.4.x, the thread is placed at the front of the queue
4154 #. In 2.0.x, the Right Thing happened: the thread went to the back -- MTK
4156 #: build/C/man7/sched.7:164
4158 "A call to B<sched_setscheduler>(2), B<sched_setparam>(2), or "
4159 "B<sched_setattr>(2) will put the B<SCHED_FIFO> (or B<SCHED_RR>) thread "
4160 "identified by I<pid> at the start of the list if it was runnable. As a "
4161 "consequence, it may preempt the currently running thread if it has the same "
4162 "priority. (POSIX.1-2001 specifies that the thread should go to the end of "
4167 #: build/C/man7/sched.7:168
4168 msgid "A thread calling B<sched_yield>(2) will be put at the end of the list."
4172 #: build/C/man7/sched.7:172
4174 "No other events will move a thread scheduled under the B<SCHED_FIFO> policy "
4175 "in the wait list of runnable threads with equal static priority."
4179 #: build/C/man7/sched.7:177
4181 "A B<SCHED_FIFO> thread runs until either it is blocked by an I/O request, it "
4182 "is preempted by a higher priority thread, or it calls B<sched_yield>(2)."
4186 #: build/C/man7/sched.7:177
4188 msgid "SCHED_RR: Round-robin scheduling"
4191 #. On Linux 2.4, the length of the RR interval is influenced
4192 #. by the process nice value -- MTK
4194 #: build/C/man7/sched.7:196
4196 "B<SCHED_RR> is a simple enhancement of B<SCHED_FIFO>. Everything described "
4197 "above for B<SCHED_FIFO> also applies to B<SCHED_RR>, except that each thread "
4198 "is allowed to run only for a maximum time quantum. If a B<SCHED_RR> thread "
4199 "has been running for a time period equal to or longer than the time quantum, "
4200 "it will be put at the end of the list for its priority. A B<SCHED_RR> "
4201 "thread that has been preempted by a higher priority thread and subsequently "
4202 "resumes execution as a running thread will complete the unexpired portion of "
4203 "its round-robin time quantum. The length of the time quantum can be "
4204 "retrieved using B<sched_rr_get_interval>(2)."
4208 #: build/C/man7/sched.7:196
4210 msgid "SCHED_DEADLINE: Sporadic task model deadline scheduling"
4214 #: build/C/man7/sched.7:208
4216 "Since version 3.14, Linux provides a deadline scheduling policy "
4217 "(B<SCHED_DEADLINE>). This policy is currently implemented using GEDF "
4218 "(Global Earliest Deadline First) in conjunction with CBS (Constant "
4219 "Bandwidth Server). To set and fetch this policy and associated attributes, "
4220 "one must use the Linux-specific B<sched_setattr>(2) and B<sched_getattr>(2) "
4225 #: build/C/man7/sched.7:226
4227 "A sporadic task is one that has a sequence of jobs, where each job is "
4228 "activated at most once per period. Each job also has a I<relative "
4229 "deadline>, before which it should finish execution, and a I<computation "
4230 "time>, which is the CPU time necessary for executing the job. The moment "
4231 "when a task wakes up because a new job has to be executed is called the "
4232 "I<arrival time> (also referred to as the request time or release time). The "
4233 "I<start time> is the time at which a task starts its execution. The "
4234 "I<absolute deadline> is thus obtained by adding the relative deadline to the "
4239 #: build/C/man7/sched.7:228
4240 msgid "The following diagram clarifies these terms:"
4244 #: build/C/man7/sched.7:239
4247 "arrival/wakeup absolute deadline\n"
4251 "-----x--------xooooooooooooooooo--------x--------x---\n"
4252 " |E<lt>- comp. time -E<gt>|\n"
4253 " |E<lt>------- relative deadline ------E<gt>|\n"
4254 " |E<lt>-------------- period -------------------E<gt>|\n"
4258 #: build/C/man7/sched.7:258
4260 "When setting a B<SCHED_DEADLINE> policy for a thread using "
4261 "B<sched_setattr>(2), one can specify three parameters: I<Runtime>, "
4262 "I<Deadline>, and I<Period>. These parameters do not necessarily correspond "
4263 "to the aforementioned terms: usual practice is to set Runtime to something "
4264 "bigger than the average computation time (or worst-case execution time for "
4265 "hard real-time tasks), Deadline to the relative deadline, and Period to the "
4266 "period of the task. Thus, for B<SCHED_DEADLINE> scheduling, we have:"
4270 #: build/C/man7/sched.7:269
4273 "arrival/wakeup absolute deadline\n"
4277 "-----x--------xooooooooooooooooo--------x--------x---\n"
4278 " |E<lt>-- Runtime -------E<gt>|\n"
4279 " |E<lt>----------- Deadline -----------E<gt>|\n"
4280 " |E<lt>-------------- Period -------------------E<gt>|\n"
4283 #. FIXME It looks as though specifying sched_period as 0 means
4284 #. "make sched_period the same as sched_deadline".
4285 #. This needs to be documented.
4287 #: build/C/man7/sched.7:289
4289 "The three deadline-scheduling parameters correspond to the I<sched_runtime>, "
4290 "I<sched_deadline>, and I<sched_period> fields of the I<sched_attr> "
4291 "structure; see B<sched_setattr>(2). These fields express value in "
4292 "nanoseconds. If I<sched_period> is specified as 0, then it is made the same "
4293 "as I<sched_deadline>."
4297 #: build/C/man7/sched.7:291
4298 msgid "The kernel requires that:"
4302 #: build/C/man7/sched.7:293
4304 msgid " sched_runtime E<lt>= sched_deadline E<lt>= sched_period\n"
4307 #. See __checkparam_dl in kernel/sched/core.c
4309 #: build/C/man7/sched.7:303
4311 "In addition, under the current implementation, all of the parameter values "
4312 "must be at least 1024 (i.e., just over one microsecond, which is the "
4313 "resolution of the implementation), and less than 2^63. If any of these "
4314 "checks fails, B<sched_setattr>(2) fails with the error B<EINVAL>."
4318 #: build/C/man7/sched.7:306
4320 "The CBS guarantees non-interference between tasks, by throttling threads "
4321 "that attempt to over-run their specified Runtime."
4325 #: build/C/man7/sched.7:319
4327 "To ensure deadline scheduling guarantees, the kernel must prevent situations "
4328 "where the set of B<SCHED_DEADLINE> threads is not feasible (schedulable) "
4329 "within the given constraints. The kernel thus performs an admittance test "
4330 "when setting or changing B<SCHED_DEADLINE> policy and attributes. This "
4331 "admission test calculates whether the change is feasible; if it is not "
4332 "B<sched_setattr>(2) fails with the error B<EBUSY>."
4336 #: build/C/man7/sched.7:325
4338 "For example, it is required (but not necessarily sufficient) for the total "
4339 "utilization to be less than or equal to the total number of CPUs available, "
4340 "where, since each thread can maximally run for Runtime per Period, that "
4341 "thread's utilization is its Runtime divided by its Period."
4345 #: build/C/man7/sched.7:336
4347 "In order to fulfil the guarantees that are made when a thread is admitted to "
4348 "the B<SCHED_DEADLINE> policy, B<SCHED_DEADLINE> threads are the highest "
4349 "priority (user controllable) threads in the system; if any B<SCHED_DEADLINE> "
4350 "thread is runnable, it will preempt any thread scheduled under one of the "
4355 #: build/C/man7/sched.7:344
4357 "A call to B<fork>(2) by a thread scheduled under the B<SCHED_DEADLINE> "
4358 "policy will fail with the error B<EAGAIN>, unless the thread has its "
4359 "reset-on-fork flag set (see below)."
4363 #. FIXME Calling sched_getparam() on a SCHED_DEADLINE thread
4364 #. fails with EINVAL, but sched_getscheduler() succeeds.
4365 #. Is that intended? (Why?)
4367 #: build/C/man7/sched.7:355
4369 "A B<SCHED_DEADLINE> thread that calls B<sched_yield>(2) will yield the "
4370 "current job and wait for a new period to begin."
4374 #: build/C/man7/sched.7:355
4376 msgid "SCHED_OTHER: Default Linux time-sharing scheduling"
4380 #: build/C/man7/sched.7:372
4382 "B<SCHED_OTHER> can be used at only static priority 0. B<SCHED_OTHER> is the "
4383 "standard Linux time-sharing scheduler that is intended for all threads that "
4384 "do not require the special real-time mechanisms. The thread to run is "
4385 "chosen from the static priority 0 list based on a I<dynamic> priority that "
4386 "is determined only inside this list. The dynamic priority is based on the "
4387 "nice value (set by B<nice>(2), B<setpriority>(2), or B<sched_setattr>(2)) "
4388 "and increased for each time quantum the thread is ready to run, but denied "
4389 "to run by the scheduler. This ensures fair progress among all "
4390 "B<SCHED_OTHER> threads."
4394 #: build/C/man7/sched.7:372
4396 msgid "SCHED_BATCH: Scheduling batch processes"
4400 #: build/C/man7/sched.7:384
4402 "(Since Linux 2.6.16.) B<SCHED_BATCH> can be used only at static priority "
4403 "0. This policy is similar to B<SCHED_OTHER> in that it schedules the thread "
4404 "according to its dynamic priority (based on the nice value). The difference "
4405 "is that this policy will cause the scheduler to always assume that the "
4406 "thread is CPU-intensive. Consequently, the scheduler will apply a small "
4407 "scheduling penalty with respect to wakeup behavior, so that this thread is "
4408 "mildly disfavored in scheduling decisions."
4411 #. The following paragraph is drawn largely from the text that
4412 #. accompanied Ingo Molnar's patch for the implementation of
4414 #. commit b0a9499c3dd50d333e2aedb7e894873c58da3785
4416 #: build/C/man7/sched.7:394
4418 "This policy is useful for workloads that are noninteractive, but do not want "
4419 "to lower their nice value, and for workloads that want a deterministic "
4420 "scheduling policy without interactivity causing extra preemptions (between "
4421 "the workload's tasks)."
4425 #: build/C/man7/sched.7:394
4427 msgid "SCHED_IDLE: Scheduling very low priority jobs"
4431 #: build/C/man7/sched.7:398
4433 "(Since Linux 2.6.23.) B<SCHED_IDLE> can be used only at static priority 0; "
4434 "the process nice value has no influence for this policy."
4438 #: build/C/man7/sched.7:406
4440 "This policy is intended for running jobs at extremely low priority (lower "
4441 "even than a +19 nice value with the B<SCHED_OTHER> or B<SCHED_BATCH> "
4446 #: build/C/man7/sched.7:406
4448 msgid "Resetting scheduling policy for child processes"
4452 #: build/C/man7/sched.7:412
4454 "Each thread has a reset-on-fork scheduling flag. When this flag is set, "
4455 "children created by B<fork>(2) do not inherit privileged scheduling "
4456 "policies. The reset-on-fork flag can be set by either:"
4460 #: build/C/man7/sched.7:421
4462 "ORing the B<SCHED_RESET_ON_FORK> flag into the I<policy> argument when "
4463 "calling B<sched_setscheduler>(2) (since Linux 2.6.32); or"
4467 #: build/C/man7/sched.7:428
4469 "specifying the B<SCHED_FLAG_RESET_ON_FORK> flag in I<attr.sched_flags> when "
4470 "calling B<sched_setattr>(2)."
4474 #: build/C/man7/sched.7:434
4476 "Note that the constants used with these two APIs have different names. The "
4477 "state of the reset-on-fork flag can analogously be retrieved using "
4478 "B<sched_getscheduler>(2) and B<sched_getattr>(2)."
4482 #: build/C/man7/sched.7:441
4484 "The reset-on-fork feature is intended for media-playback applications, and "
4485 "can be used to prevent applications evading the B<RLIMIT_RTTIME> resource "
4486 "limit (see B<getrlimit>(2)) by creating multiple child processes."
4490 #: build/C/man7/sched.7:444
4492 "More precisely, if the reset-on-fork flag is set, the following rules apply "
4493 "for subsequently created children:"
4497 #: build/C/man7/sched.7:452
4499 "If the calling thread has a scheduling policy of B<SCHED_FIFO> or "
4500 "B<SCHED_RR>, the policy is reset to B<SCHED_OTHER> in child processes."
4504 #: build/C/man7/sched.7:455
4506 "If the calling process has a negative nice value, the nice value is reset to "
4507 "zero in child processes."
4511 #: build/C/man7/sched.7:463
4513 "After the reset-on-fork flag has been enabled, it can be reset only if the "
4514 "thread has the B<CAP_SYS_NICE> capability. This flag is disabled in child "
4515 "processes created by B<fork>(2)."
4519 #: build/C/man7/sched.7:463
4521 msgid "Privileges and resource limits"
4525 #: build/C/man7/sched.7:475
4527 "In Linux kernels before 2.6.12, only privileged (B<CAP_SYS_NICE>) threads "
4528 "can set a nonzero static priority (i.e., set a real-time scheduling "
4529 "policy). The only change that an unprivileged thread can make is to set the "
4530 "B<SCHED_OTHER> policy, and this can be done only if the effective user ID of "
4531 "the caller matches the real or effective user ID of the target thread (i.e., "
4532 "the thread specified by I<pid>) whose policy is being changed."
4536 #: build/C/man7/sched.7:481
4538 "A thread must be privileged (B<CAP_SYS_NICE>) in order to set or modify a "
4539 "B<SCHED_DEADLINE> policy."
4543 #: build/C/man7/sched.7:491
4545 "Since Linux 2.6.12, the B<RLIMIT_RTPRIO> resource limit defines a ceiling on "
4546 "an unprivileged thread's static priority for the B<SCHED_RR> and "
4547 "B<SCHED_FIFO> policies. The rules for changing scheduling policy and "
4548 "priority are as follows:"
4552 #: build/C/man7/sched.7:499
4554 "If an unprivileged thread has a nonzero B<RLIMIT_RTPRIO> soft limit, then it "
4555 "can change its scheduling policy and priority, subject to the restriction "
4556 "that the priority cannot be set to a value higher than the maximum of its "
4557 "current priority and its B<RLIMIT_RTPRIO> soft limit."
4561 #: build/C/man7/sched.7:504
4563 "If the B<RLIMIT_RTPRIO> soft limit is 0, then the only permitted changes are "
4564 "to lower the priority, or to switch to a non-real-time policy."
4568 #: build/C/man7/sched.7:509
4570 "Subject to the same rules, another unprivileged thread can also make these "
4571 "changes, as long as the effective user ID of the thread making the change "
4572 "matches the real or effective user ID of the target thread."
4575 #. commit c02aa73b1d18e43cfd79c2f193b225e84ca497c8
4577 #: build/C/man7/sched.7:528
4579 "Special rules apply for the B<SCHED_IDLE> policy. In Linux kernels before "
4580 "2.6.39, an unprivileged thread operating under this policy cannot change its "
4581 "policy, regardless of the value of its B<RLIMIT_RTPRIO> resource limit. In "
4582 "Linux kernels since 2.6.39, an unprivileged thread can switch to either the "
4583 "B<SCHED_BATCH> or the B<SCHED_NORMAL> policy so long as its nice value falls "
4584 "within the range permitted by its B<RLIMIT_NICE> resource limit (see "
4589 #: build/C/man7/sched.7:539
4591 "Privileged (B<CAP_SYS_NICE>) threads ignore the B<RLIMIT_RTPRIO> limit; as "
4592 "with older kernels, they can make arbitrary changes to scheduling policy and "
4593 "priority. See B<getrlimit>(2) for further information on B<RLIMIT_RTPRIO>."
4597 #: build/C/man7/sched.7:539
4599 msgid "Limiting the CPU usage of real-time and deadline processes"
4603 #: build/C/man7/sched.7:552
4605 "A nonblocking infinite loop in a thread scheduled under the B<SCHED_FIFO>, "
4606 "B<SCHED_RR>, or B<SCHED_DEADLINE> policy will block all threads with lower "
4607 "priority forever. Prior to Linux 2.6.25, the only way of preventing a "
4608 "runaway real-time process from freezing the system was to run (at the "
4609 "console) a shell scheduled under a higher static priority than the tested "
4610 "application. This allows an emergency kill of tested real-time applications "
4611 "that do not block or terminate as expected."
4615 #: build/C/man7/sched.7:562
4617 "Since Linux 2.6.25, there are other techniques for dealing with runaway "
4618 "real-time and deadline processes. One of these is to use the "
4619 "B<RLIMIT_RTTIME> resource limit to set a ceiling on the CPU time that a "
4620 "real-time process may consume. See B<getrlimit>(2) for details."
4624 #: build/C/man7/sched.7:570
4626 "Since version 2.6.25, Linux also provides two I</proc> files that can be "
4627 "used to reserve a certain amount of CPU time to be used by non-real-time "
4628 "processes. Reserving some CPU time in this fashion allows some CPU time to "
4629 "be allocated to (say) a root shell that can be used to kill a runaway "
4630 "process. Both of these files specify time values in microseconds:"
4634 #: build/C/man7/sched.7:570
4636 msgid "I</proc/sys/kernel/sched_rt_period_us>"
4640 #: build/C/man7/sched.7:578
4642 "This file specifies a scheduling period that is equivalent to 100% CPU "
4643 "bandwidth. The value in this file can range from 1 to B<INT_MAX>, giving an "
4644 "operating range of 1 microsecond to around 35 minutes. The default value in "
4645 "this file is 1,000,000 (1 second)."
4649 #: build/C/man7/sched.7:578
4651 msgid "I</proc/sys/kernel/sched_rt_runtime_us>"
4655 #: build/C/man7/sched.7:591
4657 "The value in this file specifies how much of the \"period\" time can be used "
4658 "by all real-time and deadline scheduled processes on the system. The value "
4659 "in this file can range from -1 to B<INT_MAX>-1. Specifying -1 makes the "
4660 "runtime the same as the period; that is, no CPU time is set aside for "
4661 "non-real-time processes (which was the Linux behavior before kernel "
4662 "2.6.25). The default value in this file is 950,000 (0.95 seconds), meaning "
4663 "that 5% of the CPU time is reserved for processes that don't run under a "
4664 "real-time or deadline scheduling policy."
4668 #: build/C/man7/sched.7:592
4670 msgid "Response time"
4674 #. .BR request_irq (9).
4676 #: build/C/man7/sched.7:600
4678 "A blocked high priority thread waiting for I/O has a certain response time "
4679 "before it is scheduled again. The device driver writer can greatly reduce "
4680 "this response time by using a \"slow interrupt\" interrupt handler."
4684 #: build/C/man7/sched.7:600
4686 msgid "Miscellaneous"
4690 #: build/C/man7/sched.7:605
4692 "Child processes inherit the scheduling policy and parameters across a "
4693 "B<fork>(2). The scheduling policy and parameters are preserved across "
4698 #: build/C/man7/sched.7:611
4700 "Memory locking is usually needed for real-time processes to avoid paging "
4701 "delays; this can be done with B<mlock>(2) or B<mlockall>(2)."
4705 #: build/C/man7/sched.7:622
4707 "Originally, Standard Linux was intended as a general-purpose operating "
4708 "system being able to handle background processes, interactive applications, "
4709 "and less demanding real-time applications (applications that need to usually "
4710 "meet timing deadlines). Although the Linux kernel 2.6 allowed for kernel "
4711 "preemption and the newly introduced O(1) scheduler ensures that the time "
4712 "needed to schedule is fixed and deterministic irrespective of the number of "
4713 "active tasks, true real-time computing was not possible up to kernel version "
4718 #: build/C/man7/sched.7:622
4720 msgid "Real-time features in the mainline Linux kernel"
4723 #. FIXME . Probably this text will need some minor tweaking
4724 #. by about the time of 2.6.30; ask Carsten Emde about this then.
4726 #: build/C/man7/sched.7:636
4728 "From kernel version 2.6.18 onward, however, Linux is gradually becoming "
4729 "equipped with real-time capabilities, most of which are derived from the "
4730 "former I<realtime-preempt> patches developed by Ingo Molnar, Thomas "
4731 "Gleixner, Steven Rostedt, and others. Until the patches have been "
4732 "completely merged into the mainline kernel (this is expected to be around "
4733 "kernel version 2.6.30), they must be installed to achieve the best real-time "
4734 "performance. These patches are named:"
4738 #: build/C/man7/sched.7:640
4740 msgid "patch-I<kernelversion>-rtI<patchversion>\n"
4744 #: build/C/man7/sched.7:646
4746 "and can be downloaded from E<.UR "
4747 "http://www.kernel.org\\:/pub\\:/linux\\:/kernel\\:/projects\\:/rt/> E<.UE .>"
4751 #: build/C/man7/sched.7:655
4753 "Without the patches and prior to their full inclusion into the mainline "
4754 "kernel, the kernel configuration offers only the three preemption classes "
4755 "B<CONFIG_PREEMPT_NONE>, B<CONFIG_PREEMPT_VOLUNTARY>, and "
4756 "B<CONFIG_PREEMPT_DESKTOP> which respectively provide no, some, and "
4757 "considerable reduction of the worst-case scheduling latency."
4761 #: build/C/man7/sched.7:664
4763 "With the patches applied or after their full inclusion into the mainline "
4764 "kernel, the additional configuration item B<CONFIG_PREEMPT_RT> becomes "
4765 "available. If this is selected, Linux is transformed into a regular "
4766 "real-time operating system. The FIFO and RR scheduling policies are then "
4767 "used to run a thread with true real-time priority and a minimum worst-case "
4768 "scheduling latency."
4772 #: build/C/man7/sched.7:691
4774 "B<chrt>(1), B<taskset>(1), B<getpriority>(2), B<mlock>(2), B<mlockall>(2), "
4775 "B<munlock>(2), B<munlockall>(2), B<nice>(2), B<sched_get_priority_max>(2), "
4776 "B<sched_get_priority_min>(2), B<sched_getscheduler>(2), "
4777 "B<sched_getaffinity>(2), B<sched_getparam>(2), B<sched_rr_get_interval>(2), "
4778 "B<sched_setaffinity>(2), B<sched_setscheduler>(2), B<sched_setparam>(2), "
4779 "B<sched_yield>(2), B<setpriority>(2), B<pthread_getaffinity_np>(3), "
4780 "B<pthread_setaffinity_np>(3), B<sched_getcpu>(3), B<capabilities>(7), "
4785 #: build/C/man7/sched.7:695
4787 "I<Programming for the real world - POSIX.4> by Bill O. Gallmeister, O'Reilly "
4788 "& Associates, Inc., ISBN 1-56592-074-0."
4792 #: build/C/man7/sched.7:702
4794 "The Linux kernel source files I<Documentation/scheduler/sched-deadline.txt>, "
4795 "I<Documentation/scheduler/sched-rt-group.txt>, "
4796 "I<Documentation/scheduler/sched-design-CFS.txt>, and "
4797 "I<Documentation/scheduler/sched-nice-design.txt>"
4801 #: build/C/man2/setns.2:8
4807 #: build/C/man2/setns.2:8
4813 #: build/C/man2/setns.2:11
4814 msgid "setns - reassociate thread with a namespace"
4818 #: build/C/man2/setns.2:17
4820 msgid "B<int setns(int >I<fd>B<, int >I<nstype>B<);>\n"
4824 #: build/C/man2/setns.2:21
4826 "Given a file descriptor referring to a namespace, reassociate the calling "
4827 "thread with that namespace."
4831 #: build/C/man2/setns.2:34
4833 "The I<fd> argument is a file descriptor referring to one of the namespace "
4834 "entries in a I</proc/[pid]/ns/> directory; see B<namespaces>(7) for further "
4835 "information on I</proc/[pid]/ns/>. The calling thread will be reassociated "
4836 "with the corresponding namespace, subject to any constraints imposed by the "
4837 "I<nstype> argument."
4841 #: build/C/man2/setns.2:40
4843 "The I<nstype> argument specifies which type of namespace the calling thread "
4844 "may be reassociated with. This argument can have one of the following "
4849 #: build/C/man2/setns.2:40
4855 #: build/C/man2/setns.2:43
4856 msgid "Allow any type of namespace to be joined."
4860 #: build/C/man2/setns.2:43
4862 msgid "B<CLONE_NEWIPC> (since Linux 3.0)"
4866 #: build/C/man2/setns.2:47
4867 msgid "I<fd> must refer to an IPC namespace."
4871 #: build/C/man2/setns.2:47
4873 msgid "B<CLONE_NEWNET> (since Linux 3.0)"
4877 #: build/C/man2/setns.2:51
4878 msgid "I<fd> must refer to a network namespace."
4882 #: build/C/man2/setns.2:51
4884 msgid "B<CLONE_NEWNS> (since Linux 3.8)"
4888 #: build/C/man2/setns.2:55
4889 msgid "I<fd> must refer to a mount namespace."
4893 #: build/C/man2/setns.2:55 build/C/man2/unshare.2:149
4895 msgid "B<CLONE_NEWPID> (since Linux 3.8)"
4899 #: build/C/man2/setns.2:59
4900 msgid "I<fd> must refer to a descendant PID namespace."
4904 #: build/C/man2/setns.2:59 build/C/man2/unshare.2:176
4906 msgid "B<CLONE_NEWUSER> (since Linux 3.8)"
4910 #: build/C/man2/setns.2:63
4911 msgid "I<fd> must refer to a user namespace."
4915 #: build/C/man2/setns.2:63
4917 msgid "B<CLONE_NEWUTS> (since Linux 3.0)"
4921 #: build/C/man2/setns.2:67
4922 msgid "I<fd> must refer to a UTS namespace."
4926 #: build/C/man2/setns.2:82
4928 "Specifying I<nstype> as 0 suffices if the caller knows (or does not care) "
4929 "what type of namespace is referred to by I<fd>. Specifying a nonzero value "
4930 "for I<nstype> is useful if the caller does not know what type of namespace "
4931 "is referred to by I<fd> and wants to ensure that the namespace is of a "
4932 "particular type. (The caller might not know the type of the namespace "
4933 "referred to by I<fd> if the file descriptor was opened by another process "
4934 "and, for example, passed to the caller via a UNIX domain socket.)"
4938 #: build/C/man2/setns.2:97
4940 "B<CLONE_NEWPID> behaves somewhat differently from the other I<nstype> "
4941 "values: reassociating the calling thread with a PID namespace changes only "
4942 "the PID namespace that child processes of the caller will be created in; it "
4943 "does not change the PID namespace of the caller itself. Reassociating with "
4944 "a PID namespace is allowed only if the PID namespace specified by I<fd> is a "
4945 "descendant (child, grandchild, etc.) of the PID namespace of the caller. "
4946 "For further details on PID namespaces, see B<pid_namespaces>(7)."
4949 #. See kernel/user_namespace.c:userns_install() [3.8 source]
4950 #. commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
4951 #. https://lwn.net/Articles/543273/
4953 #: build/C/man2/setns.2:124
4955 "A process reassociating itself with a user namespace must have the "
4956 "B<CAP_SYS_ADMIN> capability in the target user namespace. Upon successfully "
4957 "joining a user namespace, a process is granted all capabilities in that "
4958 "namespace, regardless of its user and group IDs. A multithreaded process "
4959 "may not change user namespace with B<setns>(). It is not permitted to use "
4960 "B<setns>() to reenter the caller's current user namespace. This prevents a "
4961 "caller that has dropped capabilities from regaining those capabilities via a "
4962 "call to B<setns>(). For security reasons, a process can't join a new user "
4963 "namespace if it is sharing filesystem-related attributes (the attributes "
4964 "whose sharing is controlled by the B<clone>(2) B<CLONE_FS> flag) with "
4965 "another process. For further details on user namespaces, see "
4966 "B<user_namespaces>(7)."
4969 #. Above check is in fs/namespace.c:mntns_install() [3.8 source]
4971 #: build/C/man2/setns.2:138
4973 "A process may not be reassociated with a new mount namespace if it is "
4974 "multithreaded. Changing the mount namespace requires that the caller "
4975 "possess both B<CAP_SYS_CHROOT> and B<CAP_SYS_ADMIN> capabilities in its own "
4976 "user namespace and B<CAP_SYS_ADMIN> in the target mount namespace. See "
4977 "B<user_namespaces>(7) for details on the interaction of user namespaces and "
4982 #: build/C/man2/setns.2:145
4984 "On success, B<setns>() returns 0. On failure, -1 is returned and I<errno> "
4985 "is set to indicate the error."
4989 #: build/C/man2/setns.2:150
4990 msgid "I<fd> is not a valid file descriptor."
4994 #: build/C/man2/setns.2:155
4996 "I<fd> refers to a namespace whose type does not match that specified in "
5001 #: build/C/man2/setns.2:159
5002 msgid "There is problem with reassociating the thread with the specified namespace."
5006 #: build/C/man2/setns.2:164
5008 "The caller tried to join an ancestor (parent, grandparent, etc...) pid "
5013 #: build/C/man2/setns.2:168
5015 "The caller attempted to join the user namespace in which it is already a "
5019 #. commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
5021 #: build/C/man2/setns.2:175
5023 "The caller shares filesystem (B<CLONE_FS>) state (in particular, the root "
5024 "directory) with other processes and tried to join a new user namespace."
5027 #. See kernel/user_namespace.c::userns_install() [kernel 3.15 sources]
5029 #: build/C/man2/setns.2:179
5030 msgid "The caller is multithreaded and tried to join a new user namespace."
5034 #: build/C/man2/setns.2:182
5035 msgid "Cannot allocate sufficient memory to change the specified namespace."
5039 #: build/C/man2/setns.2:186
5040 msgid "The calling thread did not have the required capability for this operation."
5044 #: build/C/man2/setns.2:191
5046 "The B<setns>() system call first appeared in Linux in kernel 3.0; library "
5047 "support was added to glibc in version 2.14."
5051 #: build/C/man2/setns.2:195
5052 msgid "The B<setns>() system call is Linux-specific."
5056 #: build/C/man2/setns.2:201
5058 "Not all of the attributes that can be shared when a new thread is created "
5059 "using B<clone>(2) can be changed using B<setns>()."
5063 #: build/C/man2/setns.2:210
5065 "The program below takes two or more arguments. The first argument specifies "
5066 "the pathname of a namespace file in an existing I</proc/[pid]/ns/> "
5067 "directory. The remaining arguments specify a command and its arguments. "
5068 "The program opens the namespace file, joins that namespace using B<setns>(), "
5069 "and executes the specified command inside that namespace."
5073 #: build/C/man2/setns.2:220
5075 "The following shell session demonstrates the use of this program (compiled "
5076 "as a binary named I<ns_exec>) in conjunction with the B<CLONE_NEWUTS> "
5077 "example program in the B<clone>(2) man page (complied as a binary named "
5082 #: build/C/man2/setns.2:228
5084 "We begin by executing the example program in B<clone>(2) in the "
5085 "background. That program creates a child in a separate UTS namespace. The "
5086 "child changes the hostname in its namespace, and then both processes display "
5087 "the hostnames in their UTS namespaces, so that we can see that they are "
5092 #: build/C/man2/setns.2:240
5095 "$ B<su> # Need privilege for namespace operations\n"
5097 "# B<./newuts bizarro &>\n"
5099 "clone() returned 3550\n"
5100 "uts.nodename in child: bizarro\n"
5101 "uts.nodename in parent: antero\n"
5102 "# B<uname -n> # Verify hostname in the shell\n"
5107 #: build/C/man2/setns.2:247
5109 "We then run the program shown below, using it to execute a shell. Inside "
5110 "that shell, we verify that the hostname is the one set by the child created "
5111 "by the first program:"
5115 #: build/C/man2/setns.2:253
5118 "# B<./ns_exec /proc/3550/ns/uts /bin/bash>\n"
5119 "# B<uname -n> # Executed in shell started by ns_exec\n"
5124 #: build/C/man2/setns.2:263
5127 "#define _GNU_SOURCE\n"
5128 "#include E<lt>fcntl.hE<gt>\n"
5129 "#include E<lt>sched.hE<gt>\n"
5130 "#include E<lt>unistd.hE<gt>\n"
5131 "#include E<lt>stdlib.hE<gt>\n"
5132 "#include E<lt>stdio.hE<gt>\n"
5136 #: build/C/man2/setns.2:271
5140 "main(int argc, char *argv[])\n"
5146 #: build/C/man2/setns.2:276
5149 " if (argc E<lt> 3) {\n"
5150 " fprintf(stderr, \"%s /proc/PID/ns/FILE cmd args...\\en\", "
5152 " exit(EXIT_FAILURE);\n"
5157 #: build/C/man2/setns.2:280
5160 " fd = open(argv[1], O_RDONLY); /* Get descriptor for namespace */\n"
5162 " errExit(\"open\");\n"
5166 #: build/C/man2/setns.2:283
5169 " if (setns(fd, 0) == -1) /* Join that namespace */\n"
5170 " errExit(\"setns\");\n"
5174 #: build/C/man2/setns.2:287
5177 " execvp(argv[2], &argv[2]); /* Execute a command in namespace */\n"
5178 " errExit(\"execvp\");\n"
5183 #: build/C/man2/setns.2:295
5185 "B<clone>(2), B<fork>(2), B<unshare>(2), B<vfork>(2), B<namespaces>(7), "
5190 #: build/C/man2/unshare.2:20
5196 #: build/C/man2/unshare.2:23
5197 msgid "unshare - disassociate parts of the process execution context"
5201 #: build/C/man2/unshare.2:28
5203 msgid "B<int unshare(int >I<flags>B<);>\n"
5207 #: build/C/man2/unshare.2:36
5208 msgid "B<unshare>():"
5212 #: build/C/man2/unshare.2:62
5214 "B<unshare>() allows a process to disassociate parts of its execution "
5215 "context that are currently being shared with other processes. Part of the "
5216 "execution context, such as the mount namespace, is shared implicitly when a "
5217 "new process is created using B<fork>(2) or B<vfork>(2), while other parts, "
5218 "such as virtual memory, may be shared by explicit request when creating a "
5219 "process using B<clone>(2)."
5223 #: build/C/man2/unshare.2:67
5225 "The main use of B<unshare>() is to allow a process to control its shared "
5226 "execution context without creating a new process."
5230 #: build/C/man2/unshare.2:74
5232 "The I<flags> argument is a bit mask that specifies which parts of the "
5233 "execution context should be unshared. This argument is specified by ORing "
5234 "together zero or more of the following constants:"
5238 #: build/C/man2/unshare.2:74
5240 msgid "B<CLONE_FILES>"
5244 #: build/C/man2/unshare.2:82
5246 "Reverse the effect of the B<clone>(2) B<CLONE_FILES> flag. Unshare the "
5247 "file descriptor table, so that the calling process no longer shares its file "
5248 "descriptors with any other process."
5252 #: build/C/man2/unshare.2:82
5258 #: build/C/man2/unshare.2:96
5260 "Reverse the effect of the B<clone>(2) B<CLONE_FS> flag. Unshare filesystem "
5261 "attributes, so that the calling process no longer shares its root directory "
5262 "(B<chroot>(2)), current directory (B<chdir>(2)), or umask (B<umask>(2)) "
5263 "attributes with any other process."
5267 #: build/C/man2/unshare.2:113
5269 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWIPC> flag. "
5270 "Unshare the System\\ V IPC namespace, so that the calling process has a "
5271 "private copy of the System\\ V IPC namespace which is not shared with any "
5272 "other process. Specifying this flag automatically implies B<CLONE_SYSVSEM> "
5273 "as well. Use of B<CLONE_NEWIPC> requires the B<CAP_SYS_ADMIN> capability."
5277 #: build/C/man2/unshare.2:128
5279 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNET> flag. "
5280 "Unshare the network namespace, so that the calling process is moved into a "
5281 "new network namespace which is not shared with any previously existing "
5282 "process. Use of B<CLONE_NEWNET> requires the B<CAP_SYS_ADMIN> capability."
5286 #: build/C/man2/unshare.2:128
5288 msgid "B<CLONE_NEWNS>"
5291 #. These flag name are inconsistent:
5292 #. CLONE_NEWNS does the same thing in clone(), but CLONE_VM,
5293 #. CLONE_FS, and CLONE_FILES reverse the action of the clone()
5294 #. flags of the same name.
5296 #: build/C/man2/unshare.2:149
5298 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWNS> flag. "
5299 "Unshare the mount namespace, so that the calling process has a private copy "
5300 "of its namespace which is not shared with any other process. Specifying "
5301 "this flag automatically implies B<CLONE_FS> as well. Use of B<CLONE_NEWNS> "
5302 "requires the B<CAP_SYS_ADMIN> capability."
5306 #: build/C/man2/unshare.2:176
5308 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWPID> flag. "
5309 "Unshare the PID namespace, so that the calling process has a new PID "
5310 "namespace for its children which is not shared with any previously existing "
5311 "process. The calling process is I<not> moved into the new namespace. The "
5312 "first child created by the calling process will have the process ID 1 and "
5313 "will assume the role of B<init>(1) in the new namespace. B<CLONE_NEWPID> "
5314 "automatically implies B<CLONE_THREAD> as well. Use of B<CLONE_NEWPID> "
5315 "requires the B<CAP_SYS_ADMIN> capability. For further information, see "
5316 "B<pid_namespaces>(7)."
5320 #: build/C/man2/unshare.2:190
5322 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWUSER> flag. "
5323 "Unshare the user namespace, so that the calling process is moved into a new "
5324 "user namespace which is not shared with any previously existing process. As "
5325 "with the child process created by B<clone>(2) with the B<CLONE_NEWUSER> "
5326 "flag, the caller obtains a full set of capabilities in the new namespace."
5329 #. commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
5330 #. https://lwn.net/Articles/543273/
5332 #: build/C/man2/unshare.2:206
5334 "B<CLONE_NEWUSER> requires that the calling process is not threaded; "
5335 "specifying B<CLONE_NEWUSER> automatically implies B<CLONE_THREAD>. Since "
5336 "Linux 3.9, B<CLONE_NEWUSER> also automatically implies B<CLONE_FS>. "
5337 "B<CLONE_NEWUSER> requires that the user ID and group ID of the calling "
5338 "process are mapped to user IDs and group IDs in the user namespace of the "
5339 "calling process at the time of the call."
5343 #: build/C/man2/unshare.2:223
5345 "This flag has the same effect as the B<clone>(2) B<CLONE_NEWUTS> flag. "
5346 "Unshare the UTS IPC namespace, so that the calling process has a private "
5347 "copy of the UTS namespace which is not shared with any other process. Use "
5348 "of B<CLONE_NEWUTS> requires the B<CAP_SYS_ADMIN> capability."
5352 #: build/C/man2/unshare.2:223
5354 msgid "B<CLONE_SYSVSEM> (since Linux 2.6.26)"
5357 #. commit 9edff4ab1f8d82675277a04e359d0ed8bf14a7b7
5358 #. CLONE_NEWNS If CLONE_SIGHAND is set and signals are also being shared
5359 #. (i.e., current->signal->count > 1), force CLONE_THREAD.
5361 #: build/C/man2/unshare.2:243
5363 "This flag reverses the effect of the B<clone>(2) B<CLONE_SYSVSEM> flag. "
5364 "Unshare System\\ V semaphore adjustment (I<semadj>) values, so that the "
5365 "calling process has a new empty I<semadj> list that is not shared with any "
5366 "other process. If this is the last process that has a reference to the "
5367 "process's current I<semadj> list, then the adjustments in that list are "
5368 "applied to the corresponding semaphores, as described in B<semop>(2)."
5371 #. As at 3.9, the following forced implications also apply,
5372 #. although the relevant flags are not yet implemented.
5373 #. If CLONE_THREAD is set force CLONE_VM.
5374 #. If CLONE_VM is set, force CLONE_SIGHAND.
5376 #. See kernel/fork.c::check_unshare_flags()
5378 #: build/C/man2/unshare.2:270
5380 "In addition, B<CLONE_THREAD>, B<CLONE_SIGHAND>, and B<CLONE_VM> can be "
5381 "specified in I<flags> if the caller is single threaded (i.e., it is not "
5382 "sharing its address space with another process or thread). In this case, "
5383 "these flags have no effect. (Note also that specifying B<CLONE_THREAD> "
5384 "automatically implies B<CLONE_VM>, and specifying B<CLONE_VM> automatically "
5385 "implies B<CLONE_SIGHAND>.) If the process is multithreaded, then the use of "
5386 "these flags results in an error."
5390 #: build/C/man2/unshare.2:277
5392 "If I<flags> is specified as zero, then B<unshare>() is a no-op; no changes "
5393 "are made to the calling process's execution context."
5397 #: build/C/man2/unshare.2:282
5399 "On success, zero returned. On failure, -1 is returned and I<errno> is set "
5400 "to indicate the error."
5404 #: build/C/man2/unshare.2:287
5405 msgid "An invalid bit was specified in I<flags>."
5409 #: build/C/man2/unshare.2:296
5411 "B<CLONE_THREAD>, B<CLONE_SIGHAND>, or B<CLONE_VM> was specified in I<flags>, "
5412 "and the caller is multithreaded."
5416 #: build/C/man2/unshare.2:300
5418 "Cannot allocate sufficient memory to copy parts of caller's context that "
5419 "need to be unshared."
5423 #: build/C/man2/unshare.2:303
5424 msgid "The calling process did not have the required privileges for this operation."
5428 #: build/C/man2/unshare.2:334
5429 msgid "The B<unshare>() system call was added to Linux in kernel 2.6.16."
5433 #: build/C/man2/unshare.2:338
5434 msgid "The B<unshare>() system call is Linux-specific."
5437 #. FIXME all of the following needs to be reviewed for the current kernel
5438 #. However, we can do unshare(CLONE_SIGHAND) if CLONE_SIGHAND
5439 #. was not specified when doing clone(); i.e., unsharing
5440 #. signal handlers is permitted if we are not actually
5441 #. sharing signal handlers. mtk
5442 #. However, we can do unshare(CLONE_VM) if CLONE_VM
5443 #. was not specified when doing clone(); i.e., unsharing
5444 #. virtual memory is permitted if we are not actually
5445 #. sharing virtual memory. mtk
5449 #. The current implementation of unshare does not allow unsharing of
5450 #. signals and signal handlers. Signals are complex to begin with and
5451 #. to unshare signals and/or signal handlers of a currently running
5452 #. process is even more complex. If in the future there is a specific
5453 #. need to allow unsharing of signals and/or signal handlers, it can
5454 #. be incrementally added to unshare without affecting legacy
5455 #. applications using unshare.
5457 #: build/C/man2/unshare.2:372
5459 "Not all of the process attributes that can be shared when a new process is "
5460 "created using B<clone>(2) can be unshared using B<unshare>(). In "
5461 "particular, as at kernel 3.8, B<unshare>() does not implement flags that "
5462 "reverse the effects of B<CLONE_SIGHAND>, B<CLONE_THREAD>, or B<CLONE_VM>. "
5463 "Such functionality may be added in the future, if required."
5467 #: build/C/man2/unshare.2:381
5469 "The program below provides a simple implementation of the B<unshare>(1) "
5470 "command, which unshares one or more namespaces and executes the command "
5471 "supplied in its command-line arguments. Here's an example of the use of "
5472 "this program, running a shell in a new mount namespace, and verifying that "
5473 "the original shell and the new shell are in separate mount namespaces:"
5477 #: build/C/man2/unshare.2:390
5480 "$ B<readlink /proc/$$/ns/mnt>\n"
5481 "mnt:[4026531840]\n"
5482 "$ B<sudo ./unshare -m /bin/bash>\n"
5483 "[sudo] password for cecilia:\n"
5484 "# B<readlink /proc/$$/ns/mnt>\n"
5485 "mnt:[4026532325]\n"
5489 #: build/C/man2/unshare.2:396
5491 "The differing output of the two B<readlink>(1) commands shows that the two "
5492 "shells are in different mount namespaces."
5496 #: build/C/man2/unshare.2:400
5498 msgid "/* unshare.c\n"
5502 #: build/C/man2/unshare.2:409
5505 " A simple implementation of the unshare(1) command: unshare\n"
5506 " namespaces and execute a command.\n"
5508 "#define _GNU_SOURCE\n"
5509 "#include E<lt>sched.hE<gt>\n"
5510 "#include E<lt>unistd.hE<gt>\n"
5511 "#include E<lt>stdlib.hE<gt>\n"
5512 "#include E<lt>stdio.hE<gt>\n"
5516 #: build/C/man2/unshare.2:412
5519 "/* A simple error-handling function: print an error message based\n"
5520 " on the value in \\(aqerrno\\(aq and terminate the calling process */\n"
5524 #: build/C/man2/unshare.2:429
5528 "usage(char *pname)\n"
5530 " fprintf(stderr, \"Usage: %s [options] program [arg...]\\en\", pname);\n"
5531 " fprintf(stderr, \"Options can be:\\en\");\n"
5532 " fprintf(stderr, \" -i unshare IPC namespace\\en\");\n"
5533 " fprintf(stderr, \" -m unshare mount namespace\\en\");\n"
5534 " fprintf(stderr, \" -n unshare network namespace\\en\");\n"
5535 " fprintf(stderr, \" -p unshare PID namespace\\en\");\n"
5536 " fprintf(stderr, \" -u unshare UTS namespace\\en\");\n"
5537 " fprintf(stderr, \" -U unshare user namespace\\en\");\n"
5538 " exit(EXIT_FAILURE);\n"
5543 #: build/C/man2/unshare.2:434
5547 "main(int argc, char *argv[])\n"
5549 " int flags, opt;\n"
5553 #: build/C/man2/unshare.2:436
5555 msgid " flags = 0;\n"
5559 #: build/C/man2/unshare.2:448
5562 " while ((opt = getopt(argc, argv, \"imnpuU\")) != -1) {\n"
5564 " case \\(aqi\\(aq: flags |= CLONE_NEWIPC; break;\n"
5565 " case \\(aqm\\(aq: flags |= CLONE_NEWNS; break;\n"
5566 " case \\(aqn\\(aq: flags |= CLONE_NEWNET; break;\n"
5567 " case \\(aqp\\(aq: flags |= CLONE_NEWPID; break;\n"
5568 " case \\(aqu\\(aq: flags |= CLONE_NEWUTS; break;\n"
5569 " case \\(aqU\\(aq: flags |= CLONE_NEWUSER; break;\n"
5570 " default: usage(argv[0]);\n"
5576 #: build/C/man2/unshare.2:451
5579 " if (optind E<gt>= argc)\n"
5580 " usage(argv[0]);\n"
5584 #: build/C/man2/unshare.2:454
5587 " if (unshare(flags) == -1)\n"
5588 " errExit(\"unshare\");\n"
5592 #: build/C/man2/unshare.2:458
5595 " execvp(argv[optind], &argv[optind]);\n"
5596 " errExit(\"execvp\");\n"
5601 #: build/C/man2/unshare.2:467
5603 "B<unshare>(1), B<clone>(2), B<fork>(2), B<kcmp>(2), B<setns>(2), "
5604 "B<vfork>(2), B<namespaces>(7)"
5608 #: build/C/man2/unshare.2:470
5609 msgid "I<Documentation/unshare.txt> in the Linux kernel source tree"