Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Paolo Bonzini
On 01/16/2012 08:22 AM, Michael Tokarev wrote: On 15.01.2012 21:31, Paolo Bonzini wrote: On 01/15/2012 05:44 PM, Michael Tokarev wrote: + * stdout (temporarily) to the pipe to parent, This is a bit of a hack. There's another way -- to keep the writing pipe end in some local vari

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Michael Tokarev
On 15.01.2012 21:31, Paolo Bonzini wrote: > On 01/15/2012 05:44 PM, Michael Tokarev wrote: >> + * stdout (temporarily) to the pipe to parent, > > This is a bit of a hack. There's another way -- to keep the writing pipe end in some local variable and use that o

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Paolo Bonzini
On 01/15/2012 06:31 PM, Paolo Bonzini wrote: We're doomed anyway, and it is even good we've a small remote chance for our error message to be seen. Currently it just goes to /dev/null. No, currently it is sent from the daemon to the parent through the pipe, the parent prints it and exits wi

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Paolo Bonzini
On 01/15/2012 05:44 PM, Michael Tokarev wrote: + * stdout (temporarily) to the pipe to parent, This is a bit of a hack. There's another way -- to keep the writing pipe end in some local variable and use that one instead of STDOUT_FILENO. I can do it that way for sure, just thought

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Michael Tokarev
On 15.01.2012 20:11, Paolo Bonzini wrote: > On 01/15/2012 01:50 PM, Michael Tokarev wrote: >> On 15.01.2012 14:42, Paolo Bonzini wrote: >>> On 01/14/2012 01:39 PM, Michael Tokarev wrote: if (pid == 0) { -close(stderr_fd[0]); -ret = qemu_daemon(0, 0)

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Paolo Bonzini
On 01/15/2012 01:50 PM, Michael Tokarev wrote: On 15.01.2012 14:42, Paolo Bonzini wrote: On 01/14/2012 01:39 PM, Michael Tokarev wrote: if (pid == 0) { -close(stderr_fd[0]); -ret = qemu_daemon(0, 0); - -/* Temporarily redirect stderr to the parent'

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Michael Tokarev
On 15.01.2012 14:42, Paolo Bonzini wrote: > On 01/14/2012 01:39 PM, Michael Tokarev wrote: >> if (pid == 0) { >> -close(stderr_fd[0]); >> -ret = qemu_daemon(0, 0); >> - >> -/* Temporarily redirect stderr to the parent's pipe... */ >> -dup2(

Re: [Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-15 Thread Paolo Bonzini
On 01/14/2012 01:39 PM, Michael Tokarev wrote: if (pid == 0) { -close(stderr_fd[0]); -ret = qemu_daemon(0, 0); - -/* Temporarily redirect stderr to the parent's pipe... */ -dup2(stderr_fd[1], STDERR_FILENO); -if (ret == -1) {

[Qemu-devel] [PATCH] rework daemonizing logic in qemu-nbd

2012-01-14 Thread Michael Tokarev
qemu-nbd uses daemon(3) routine to daemonize, and while at it, it uses several hacks to make daemon(3) to work as intended. Instead of all these hacks, implement daemon(3) functionality (which is a very simple function) directly but in a way which is much more suitable for the use case. It lets us