From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119186 invoked by alias); 4 May 2015 07:44:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 119173 invoked by uid 89); 4 May 2015 07:44:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 04 May 2015 07:44:38 +0000 Received: from vapier (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with SMTP id B3B3C340AF6; Mon, 4 May 2015 07:44:35 +0000 (UTC) Date: Mon, 04 May 2015 07:44:00 -0000 From: Mike Frysinger To: Gabriel Corona Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Use a shell command as a socket for gdbserver Message-ID: <20150504074434.GE30924@vapier> Mail-Followup-To: Gabriel Corona , gdb-patches@sourceware.org References: <1430606377-16456-1-git-send-email-gabriel.corona@enst-bretagne.fr> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Uwl7UQhJk99r8jnw" Content-Disposition: inline In-Reply-To: <1430606377-16456-1-git-send-email-gabriel.corona@enst-bretagne.fr> X-IsSubscribed: yes X-SW-Source: 2015-05/txt/msg00040.txt.bz2 --Uwl7UQhJk99r8jnw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-length: 963 On 03 May 2015 00:39, Gabriel Corona wrote: > +static int open_shell_command(char* command) const, and the * should be next to "command", not "char" > + res = socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets); space before the "(" -- this comes up a lot in your patch > + else if (child == 0) > + { > + if (close (sockets[0]) < 0) > + exit (1); > + if (dup2 (sockets[1], 0) < 0 || dup2 (sockets[1], 1) < 0) > + exit (1); why not use error() instead of exit(1) ? shouldn't you close sockets[1] after the dup2 ? > + res = fork (); > + if (res < 0) > + exit (1); > + if (res != 0) > + exit (0); the double fork could use a comment > + { > + signal (SIGPIPE, SIG_IGN); > + while ((pid = waitpid (child, NULL, 0)) < 0 && errno == EINTR); > + if (pid < 0) > + error ("Could not wait for child."); > + close (sockets[1]); > + return sockets[0]; shouldn't this close sockets[1] before anything else ? -mike --Uwl7UQhJk99r8jnw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJVRyNiAAoJEEFjO5/oN/WBspsP+wb8XV8DNEx7j9uAAfqPXhRE UMl4bu9BBcHRcVpv/YwE0zq11ApnwEnV2rkFUMjmmrfn6qx71lwGnIoOlmiHneXT sv3Guc/no4h40/pfznq0zokMmrHwyZG3ahRdrXgw9Iz3zjP5qS6gku1hdrty+UaJ 2c3t1FfYFM2rBExiMt0QjN5rETj3RKI839cJXcZr8xPlRBvM2tLsMideVh5iGmOH 79/6YRVzXtDVDO+/eMc42/Au6GlJ0j6HMFWhF4Fw1yZoryRcE4bXaILE/EpbrsHV JKQrgEUbkZciNjxzaIGEy+4k5RmJGd95f6OXLRQI0abTy2jicnmKVLEECzkkbYvg hNlYwePxUsPmSPa5i/+4n45gSoquRKiGSs4wL7FQbPCfTycRMda2LOaHjOpKlZm1 Omrslnfx2qEFbUWLiTnFqQpYtNM2/WdJcs/9HFEsEHcPQczYgVTiCpHb3hj3IMUm vE0lAsMHRhh49GSQaTRiy0gfUuNjFpiswUgxQCd0LZHpkBSuB9fzTV70zqnGQJ4Z nHleLldRtBThx42qBw2I/G+F2Yl3VT48BYDrecveTAPPmuJjDhLISJxI+93Tw4LH 0dp6lQD9oEQagh4dcj3VaqxjaKJDaljZyhSgM0ap9SdZCtWWd5BCf3MZImIIZ/ks uhjqVD9V1YBut2t2Tuav =gY2T -----END PGP SIGNATURE----- --Uwl7UQhJk99r8jnw--