From: "Abu M. Muttalib" <abum@aftek.com>
To: linux-mm@kvack.org
Subject: vfork implementation...
Date: Wed, 14 Jun 2006 15:11:58 +0530 [thread overview]
Message-ID: <BKEKJNIHLJDCFGDBOHGMGEEECPAA.abum@aftek.com> (raw)
Hi,
This mail is intended for Robert Love, I hope I can find him on the list.
Please refer to Pg 24 of chapter 2 of Linux Kernel Development.
As mentioned in the description of vfork call, it is said that child is not
allowed to write to the address space, but in the following example its not
so. The child is able to write to the process address space. This program
was tested with Linux Kernel 2.6.9. Why is it so?
fork.c
----------------------------------------------------------------------------
---------------------------------------
#include <stdio.h>
unsigned char *glob_var = NULL;
void main()
{
int pid = -8,i;
pid = vfork();
if(pid < 0)
printf("\n FORK ERROR \n");
if(pid == 0)
{
unsigned char * local_var = NULL;
local_var = (unsigned char *)malloc(5);
strcpy(local_var,"ABCD");
glob_var = local_var;
printf("\nCHILD :Value of glob_var is %X local_var is %X glob_var is %c
\n",glob_var,local_var,*glob_var);
for(i=0;i<4;i++)
{
printf("\n CHAR is %c \n",glob_var[i]);
}
printf("\nCHILD1 :Value of glob_var is %X %c\n",glob_var,*(glob_var));
}
if(pid > 0)
{
printf("\nParent : Value of glob_var is %X %c\n",glob_var,*(glob_var));
free(glob_var);
printf("\nParent : Value of glob_var is %X %c\n",glob_var,*(glob_var));
exit(0);
}
}
----------------------------------------------------------------------------
---------------------------------------
Regards,
Abu.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2006-06-14 9:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-14 9:41 Abu M. Muttalib [this message]
2006-06-14 9:46 ` Gleb Natapov
2006-06-14 10:03 ` Abu M. Muttalib
2006-06-14 10:06 ` Gleb Natapov
2006-06-14 10:17 ` Abu M. Muttalib
2006-06-14 10:16 ` Gleb Natapov
2006-06-14 10:18 ` Mel Gorman
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=BKEKJNIHLJDCFGDBOHGMGEEECPAA.abum@aftek.com \
--to=abum@aftek.com \
--cc=linux-mm@kvack.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