From owner-freebsd-questions@FreeBSD.ORG Sat Jan 16 11:32:52 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 047001065670 for ; Sat, 16 Jan 2010 11:32:52 +0000 (UTC) (envelope-from polatel@gmail.com) Received: from mail-ew0-f226.google.com (mail-ew0-f226.google.com [209.85.219.226]) by mx1.freebsd.org (Postfix) with ESMTP id 70F5A8FC1E for ; Sat, 16 Jan 2010 11:32:50 +0000 (UTC) Received: by ewy26 with SMTP id 26so1733669ewy.3 for ; Sat, 16 Jan 2010 03:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:date:from:to:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=+2mP4uU6ql8Cy2OQEJRfhclgVb8Gl4oARtH4bkaww60=; b=gQwPPCn2mjToRFv/W0S3MtCyu3NxqDqiNTf3OBdfMqg7AJFw4Ph3DFhV95m7PCz6Sn l/axYIqe8D3mw9w/jZ/TG2jaAzxIWRjaHKC2+6QRPpiuoiBloatubTHEJd4LyOmvcj+X fqdLkWT7e/rQKPO4O7a21G2k+bFtkPKyYAEXU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=LHM1zRpVa9h7nWqZyT1cXDDcrxvhCG2FnRZOxxUcE/Tk0Ytd+XwndUk9lJBquwQG1u E4KtLNyxkt1UC4ynzbIGkq8VsPg27QulMENMl39VL2X4pOnZQgDn2Uo1ZTE9fkrUd4ul KBQdMkcjCW+C/vSTl9Pb27P1EpXjIfAFMSzxo= Received: by 10.213.23.201 with SMTP id s9mr3633702ebb.5.1263639777063; Sat, 16 Jan 2010 03:02:57 -0800 (PST) Received: from harikalardiyari ([78.179.35.14]) by mx.google.com with ESMTPS id 16sm2251660ewy.10.2010.01.16.03.02.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 16 Jan 2010 03:02:56 -0800 (PST) Sender: Ali Polatel Date: Sat, 16 Jan 2010 13:02:54 +0200 From: Ali Polatel To: freebsd-questions@freebsd.org Message-ID: <20100116110254.GA6142@harikalardiyari> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Subject: A question about ptrace X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jan 2010 11:32:52 -0000 --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I'm trying to port a program using ptrace from Linux to FreeBSD. For this reason I'm trying to understand how ptrace on FreeBSD works. Below is a sample program I've written which fork()'s and executes "true" after calling PT_TRACE_ME. Having read the manual page of ptrace I assume the printf() in parent should print SIGTRAP but it gives: "Segmentation fault: 11" Can someone help me figure out the problem? TIA. #include #include #include #include #include #include #include #include #include int main(void) { int status; pid_t pid; char *const myargv[] =3D { "true", NULL }; pid =3D fork(); if (0 > pid) abort(); else if (!pid) { ptrace(PT_TRACE_ME, 0, 0, 0); execvp(myargv[0], myargv); } else { assert(0 < waitpid(pid, &status, 0)); assert(WIFSTOPPED(status)); assert(0 =3D=3D ptrace(PT_TO_SCE, pid, 0, 0)); assert(0 < waitpid(pid, &status, 0)); assert(WIFSTOPPED(status)); printf("%s\n", strsignal(WSTOPSIG(status))); ptrace(PT_KILL, pid, 0, 0); return 0; } } --=20 Regards, Ali Polatel --17pEHd4RhPHOinZp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iEYEABECAAYFAktRnN4ACgkQQU4yORhF8iDB8ACgzjVd/JyWvmT9gHW79NhU9mLW CHQAoKAEmQcbPpXQQAqJQvq6Drse3jPk =I4An -----END PGP SIGNATURE----- --17pEHd4RhPHOinZp--