Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
what parent process stuff gets shared in newly created child process in Linux

When a process creates a child process using fork() then what are things of parent process that get shared with child process. like address space, memory, signal etc.

Note:-I have gone through the fork manual.still i need some more information about it.I have Google it also.but i need not get complete idea about it.Please somebody explain me deeply how the fork works.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

From Advanced Programming in the UNIX by W. Richard Stevens

The child is a copy of the parent. For example, the child gets a copy of the parent's data space, heap, and stack. Note that this is a copy for the child; the parent and the child do not share these portions of memory

one characteristic of fork is that all file descriptors that are open in the parent are duplicated in the child.

There are numerous other properties of the parent that are inherited by the child:

1. real user ID, real group ID, effective user ID, effective group ID
2. supplementary group IDs
3. process group ID
4. session ID
5. controlling terminal
6. set-user-ID flag and set-group-ID flag
7. current working directory
8. root directory
9. file mode creation mask
10. signal mask and dispositions
11. the close-on-exec flag for any open file descriptors
12. environment
13. attached shared memory segments
14. resource limits
15. Memory mappings

The differences between the parent and child are

1. the return value from fork
2. the process IDs are different
3. the two processes have different parent process IDs—the parent process ID of the     child is the parent; the parent process ID of the parent doesn't change
4. the child's values for tms_utime, tms_stime, tms_cutime, and tms_ustime are set to 0
5. file locks set by the parent are not inherited by the child
6. pending alarms are cleared for the child
7. the set of pending signals for the child is set to the empty set
over 4 years ago · Santiago Trujillo Relatório

0

Any reference to Stevens is normally a good reference in my book. However, one thing Stevens doesn't do is give Linux specific answers, and the clone system call did not exist when Stevens wrote his book.

Given you've tagged this Linux, I am supposing you want the Linux specific answer, which you'll find with man clone. This gives you the entire list of things that might or might not be shared with fork(), as fork() is implemented using clone(). From memory, fork() uses clone() passing no flags, (i.e. a 0). The manpage for clone() will thus tell you exactly what it does and does not copy.

There is a good explanation here: https://unix.stackexchange.com/questions/87551/which-file-in-kernel-specifies-fork-vfork-to-use-sys-clone-system-call

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda