From: "Sébastien Paumier" <sebastien.paumier@univ-mlv.fr>
To: linux-kernel@vger.kernel.org
Subject: PROBLEM: getpid() returning same value as getppid()
Date: Wed, 26 May 2010 16:45:04 +0200 [thread overview]
Message-ID: <4BFD33F0.1060908@univ-mlv.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
Hi,
here is a bug that occurs on my kernel 2.6.31-21, maybe with older ones.
If a C program contains a function with the constructor attribute that
calls getpid(), then, a call to syscall(SYS_fork) produces a son that
obtains the same value calling getpid() or getppid().
Best regards,
Sébastien Paumier
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 510 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
void foo(void) __attribute__ ((constructor));
void foo(void) {
/* Removing this call to getpid() removes the bug */
getpid();
}
int main(void){
int i=syscall(SYS_fork);
if (0==i)
/* Big problem: the son prints the same value for getpid() and getppid() */
printf("__son : %d father : %d__\n", getpid(), getppid());
else
printf("<<father : %d son : %d>>\n", getpid(), i);
return 0;
}
next reply other threads:[~2010-05-26 15:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 14:45 Sébastien Paumier [this message]
2010-05-26 15:16 ` PROBLEM: getpid() returning same value as getppid() Nick Bowler
2010-06-02 15:02 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BFD33F0.1060908@univ-mlv.fr \
--to=sebastien.paumier@univ-mlv.fr \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox