On 02/22/2011 07:41 AM, Maheswara Reddy C - ERS, HCL Tech wrote:
> Hi All,
>
>
>
> Does this way both pid1 and pid2 run in the same network namespace? Or please
> suggest any other way
Mahesh,
please tell us what you want to do.
If you want to create a new network namespace, it is not mandatory to
use clone. The following program will create a new network stack and all
new processes will inherit this network namespace.
#include <sched.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
pid_t pid;
if (unshare(CLONE_NEWNET)) {
perror("unshare");
return 1;
}
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
if (!pid) {
execl("/bin/bash", "/bin/bash", NULL);
perror("execl");
}
return waitpid(pid, NULL, 0);
}
I recommand you read the documentation
http://lxc.sourceforge.net/doc/sigops/appcr.pdf
Thanks
-- Daniel
------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk
Collect, index and harness all the fast moving IT data generated by your
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights.
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Lxc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxc-devel