The task_struct structure has an entry nsproxy which points to namespaces associated with the task_struct.

My understanding is that task_struct can be used to represent both process and threads in the Linux kernel (please correct me if I'm wrong). If that's the case, are namespaces associated with each thread of a process s.t. different threads can be in different namespaces, or are all threads in a process in the same set of namespaces associated with the process ?

  • 1
    example in C (on a Go site): One process in many namespaces! – A.B May 2 at 22:48
  • @A.B If a program puts different threads in different namespaces, then what do the entries in /proc/$$/ns correspond to .. namespace of the main thread of the process ? Because for each thread there would be an entry in /proc/$$/task/ID/ns – Jake May 2 at 23:43
  • yes I guess so (the tgid). You could run the example and study it in /proc. Also see man unshare and man setns: there are restrictions for mount namespace and user namespace for example. – A.B May 3 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.