马磊
2012-Aug-02 09:47 UTC
[problem in `xl_cmdimpl.c`] Why pid return by fork() in parent process is not the same with pid returned by getpid()?
Hi all, In xen-4.1.2/tools/libxl/xl_cmdimpl.c : create_domain(), it starts up a child daemon process waiting for the domain death, there are several lines echo the child pid as follows: 1592 if (child1) { /*it''s in the parent*/ 1593 printf("Daemon running with PID %d\n", child1); /**it''s in the child/ 1643 LOG("Waiting for domain %s (domid %d) to die [pid %ld]", 1644 d_config.c_info.name, domid, (long)getpid()); After input `xl create xp-101.hvm`, you got `Daemon running with PID 26622` following the command line in the screen; but the xl log file lies in /var/log/xen/xl-xp-101.log contains a line `Waiting for domain xp-101 (domid 1) to die [pid 26624]`. Why 26622 != 26624? And 26622 could not be found by `ps -ef` command. What happended to that?! Thanks in advance! _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2012-Aug-02 09:55 UTC
Re: [problem in `xl_cmdimpl.c`] Why pid return by fork() in parent process is not the same with pid returned by getpid()?
On Thu, 2012-08-02 at 10:47 +0100, 马磊 wrote:> In xen-4.1.2/tools/libxl/xl_cmdimpl.c : create_domain(), it startsIf you are doing development then target xen-unstable would be preferable, especially if you are looking at (lib)xl. The xl stuff in 4.1 is effectively a preview and it has change substantially internally since 4.1.> After input `xl create xp-101.hvm`, you got `Daemon running with PID > 26622` following the command line in the screen; but the xl log file > lies in /var/log/xen/xl-xp-101.log contains a line `Waiting for domain > xp-101 (domid 1) to die [pid 26624]`. > Why 26622 != 26624? And 26622 could not be found by `ps -ef` command. > What happended to that?!There's a call to dameon in there, which will involve a double fork IIRC. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Aug-02 15:38 UTC
Re: [problem in `xl_cmdimpl.c`] Why pid return by fork() in parent process is not the same with pid returned by getpid()?
On Thu, Aug 2, 2012 at 5:55 PM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Thu, 2012-08-02 at 10:47 +0100, 马磊 wrote: > > > In xen-4.1.2/tools/libxl/xl_cmdimpl.c : create_domain(), it starts > > If you are doing development then target xen-unstable would be > preferable, especially if you are looking at (lib)xl. The xl stuff in > 4.1 is effectively a preview and it has change substantially internally > since 4.1. > > > After input `xl create xp-101.hvm`, you got `Daemon running with PID > > 26622` following the command line in the screen; but the xl log file > > lies in /var/log/xen/xl-xp-101.log contains a line `Waiting for domain > > xp-101 (domid 1) to die [pid 26624]`. > > Why 26622 != 26624? And 26622 could not be found by `ps -ef` command. > > What happended to that?! > > There''s a call to dameon in there, which will involve a double fork > IIRC. > > Ian. > >What do you mean by `double fork`? In my opinion, the parent exit after invoking waitpid, and the child goes on toward the rest of the code. The PID recorded in xl log file can''t also be found by `ps -ef` command. How should I retrive the PID of the real daemon process? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Aug-07 08:14 UTC
Re: [problem in `xl_cmdimpl.c`] Why pid return by fork() in parent process is not the same with pid returned by getpid()?
On Thu, Aug 2, 2012 at 5:55 PM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Thu, 2012-08-02 at 10:47 +0100, 马磊 wrote: > > > In xen-4.1.2/tools/libxl/xl_cmdimpl.c : create_domain(), it starts > > If you are doing development then target xen-unstable would be > preferable, especially if you are looking at (lib)xl. The xl stuff in > 4.1 is effectively a preview and it has change substantially internally > since 4.1. > > > After input `xl create xp-101.hvm`, you got `Daemon running with PID > > 26622` following the command line in the screen; but the xl log file > > lies in /var/log/xen/xl-xp-101.log contains a line `Waiting for domain > > xp-101 (domid 1) to die [pid 26624]`. > > Why 26622 != 26624? And 26622 could not be found by `ps -ef` command. > > What happended to that?! > > There''s a call to dameon in there, which will involve a double fork > IIRC. > > Ian. > > I only to see `libxl_fork` in function create_domain() who invokes fork()once, where is the second fork()? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2012-Aug-07 08:22 UTC
Re: [problem in `xl_cmdimpl.c`] Why pid return by fork() in parent process is not the same with pid returned by getpid()?
On Tue, 2012-08-07 at 09:14 +0100, 马磊 wrote:> There's a call to dameon in there, which will involve a double > fork > IIRC. > > Ian. > > I only to see `libxl_fork` in function create_domain() who invokes > fork() once, where is the second fork()?As I said (but misspelt, sorry) There's a call to daemon() there. Have you read the manpage for that function? Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Seemingly Similar Threads
- Failed to create PVHVM domU in Xen 4.4
- [PATCH] libxl: free values in XLU_ConfigSetting
- [PATCH] Add vncviewer xm compatibility options the 'xl create' command
- [PATCH 0 of 2 v2] Add vncviewer xm compatibility options
- [PATCH 1/3] libxenlight: Clean up logging arrangements