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

201
Visualizações
waitpid returns pid=0 and WIFEXITED=1 how to get pid?

Steps:

Fork and start process in a different program group
Stop process with SIGTSTP
Restart process with SIGCONT
Process ends

Problem: The SIGCHLD handler has:

waitpid(-1, &status, WNOHANG | WUNTRACED);

upon return pid=0 and WIFEXITED=1 so, the process exited, but I can't get the pid? I need the pid.

From the man page: "if WNOHANG was specified and one or more child(ren) specified by pid exist, but have not yet changed state, then 0 is returned"
But it seems the status has changed to exited.

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

0

The status is meaningless if the pid returned was 0. Think about it. A return of 0 means you have one or more children that have yet to change state. What would the state of a child that has yet to change state be? If there were multiple children, which child is the status code referencing?

This is analogous to checking errno on a successful call. Anything from a previous call can be in errno but it has nothing to do with the most recent successful call because errno is usually not set on success.

over 4 years ago · Santiago Trujillo Relatório

0

The return value of waitpid is the PID of the child that was waited for.

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