Hi, On Tue, Dec 18, 2018 at 12:33:20PM -0500, Frediano Ziglio wrote: > > > > From: Victor Toso <me@xxxxxxxxxxxxxx> > > > > And use well defined macros for standard file descriptors. > > > > Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx> > > --- > > src/vdagent/vdagent.c | 8 ++++++-- > > src/vdagentd/vdagentd.c | 8 ++++++-- > > 2 files changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c > > index f7c8b72..87dfa7c 100644 > > --- a/src/vdagent/vdagent.c > > +++ b/src/vdagent/vdagent.c > > @@ -294,9 +294,13 @@ static int daemonize(void) > > /* detach from terminal */ > > switch (fork()) { > > case 0: > > - close(0); close(1); close(2); > > + close(STDIN_FILENO); > > + close(STDOUT_FILENO); > > + close(STDERR_FILENO); > > setsid(); > > - x = open("/dev/null", O_RDWR); x = dup(x); x = dup(x); > > + x = open("/dev/null", O_RDWR); > > + x = dup(x); > > + x = dup(x); > > close(fd[0]); > > return fd[1]; > > case -1: > > diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c > > index 99683da..a2f0946 100644 > > --- a/src/vdagentd/vdagentd.c > > +++ b/src/vdagentd/vdagentd.c > > @@ -949,9 +949,13 @@ static void daemonize(void) > > /* detach from terminal */ > > switch (fork()) { > > case 0: > > - close(0); close(1); close(2); > > + close(STDIN_FILENO); > > + close(STDOUT_FILENO); > > + close(STDERR_FILENO); > > setsid(); > > - x = open("/dev/null", O_RDWR); x = dup(x); x = dup(x); > > + x = open("/dev/null", O_RDWR); > > + x = dup(x); > > + x = dup(x); > > pidfile = fopen(pidfilename, "w"); > > if (pidfile) { > > fprintf(pidfile, "%d\n", (int)getpid()); > > Sure, > Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx> Thanks, > Maybe would be also good to rename "x" to some more sensible name ? Some more warnings from coverity in regards to not checking 'x' value from open() and possible passing negative value to dup(). Clang warns on unused variable and/or not checking for errors. In the end I kept 'x' and did not address any of above (...) > OT: Looks like the 2 hunks are pretty similar, maybe factoring > out a common function? Or to rewrite it in rust :) > Frediano Cheers, Victor
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel