From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiX3f-0005HT-R9 for qemu-devel@nongnu.org; Wed, 04 Jan 2012 15:03:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RiX3Z-0000eK-Np for qemu-devel@nongnu.org; Wed, 04 Jan 2012 15:03:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RiX3Z-0000e7-Bu for qemu-devel@nongnu.org; Wed, 04 Jan 2012 15:03:29 -0500 Message-ID: <4F04B08E.9060604@redhat.com> Date: Wed, 04 Jan 2012 13:03:26 -0700 From: Eric Blake MIME-Version: 1.0 References: <1325706313-21936-1-git-send-email-lcapitulino@redhat.com> <1325706313-21936-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1325706313-21936-3-git-send-email-lcapitulino@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig6482E9D56ADA3F6409F51824" Subject: Re: [Qemu-devel] [PATCH 2/2] qemu-ga: Add the guest-suspend command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: amit.shah@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6482E9D56ADA3F6409F51824 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/04/2012 12:45 PM, Luiz Capitulino wrote: > + if (pid =3D=3D 0) { > + /* child */ > + int fd; > + > + setsid(); > + fclose(stdin); > + fclose(stdout); > + fclose(stderr); > + > + execlp(pmutils_bin, pmutils_bin, NULL); It's generally a bad idea to exec a child process without fd 0, 1, and 2 open on something, even if that something is /dev/null. POSIX says that the system may, but not must, reopen fds on your behalf, and that the child without open std descriptors is then executing in a non-conforming environment and may misbehave in unexpected manners. > + > + /*=20 > + * The exec call should not return, if it does something went = wrong. > + * In this case we try to suspend manually if 'mode' is 'hiber= nate' > + */ > + slog("could not execute %s: %s\n", pmutils_bin, strerror(errno= )); > + slog("trying to suspend using the manual method...\n"); > + > + fd =3D open(LINUX_SYS_STATE_FILE, O_WRONLY); Worse, since you _just_ closed stdin above, fd here will most likely be 0, but a O_WRONLY stdin is asking for problems. > + if (fd < 0) { > + slog("can't open file %s: %s\n", LINUX_SYS_STATE_FILE, > + strerror(errno)); Also, I have no idea where slog() writes to, but since you closed stderr, if slog() is trying to use stderr, your error messages would be invisible. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig6482E9D56ADA3F6409F51824 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJPBLCOAAoJEKeha0olJ0NqbCgH/RISy/DYmyF78Yx8tzutdBma JRfyDW/XwvlOQn1o3cJAxdc+gmMWf9BkfKUvuyqZnRkKu3fRdFkMaamPoBR6KHzW P6/rubtOQomXGAgd53mU7HDEEphDlcqelN7VBZwhZuQKtvnteyXHF9Vsa6rjlbRT IrDFy87NoUl/Yr9dHurAbJ8H9VEWYxjcwEClZVCCyhDWIbtj+FPUpu5cXN4G+Dfs BopiPZPvz56Y+bOUS0TCGiF3DV0PlwWaPLyaD2lHDxfEcCdKon12tH3y9i1Cyt+A IGttwHO8CtI+bq1oIkhljyi/21KtBqWqRm+Vol31Fz+ySb2UTjMpU5zOk40qj+c= =tRLo -----END PGP SIGNATURE----- --------------enig6482E9D56ADA3F6409F51824--