From owner-freebsd-questions Mon Feb 26 7:36: 9 2001 Delivered-To: freebsd-questions@freebsd.org Received: from trauco.colomsat.net.co (trauco.colomsat.net.co [200.13.195.2]) by hub.freebsd.org (Postfix) with ESMTP id 82A2037B401 for ; Mon, 26 Feb 2001 07:36:06 -0800 (PST) (envelope-from ycardena@yahoo.com) Received: from yahoo.com (200.13.197.13) by trauco.colomsat.net.co (NPlex 4.0.068) id 3A9156800002E19F for questions@freebsd.org; Mon, 26 Feb 2001 10:26:16 -0500 Message-ID: <3A9A783C.86B67887@yahoo.com> Date: Mon, 26 Feb 2001 10:37:32 -0500 From: "Yonny Cardenas B." Organization: Universidad de los Andes X-Mailer: Mozilla 4.73 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 To: questions@freebsd.org Subject: proc struct changes the value returned by return() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello Why p_retval[0] of the proc struct changes the value returned by return()? I am making a system call and need return succeeds (zero) or error (-1) and set errno appropriately. I have the following fragment code: int _sys_connect_socket(socktype skt, struct sockaddr_in * psa, struct proc *p) { int error; struct file *fp; register struct socket *so; /* .... */ error = socreate(AF_INET, &so, type, 0 , p); if (error) { fdp->fd_ofiles[fd] = 0; ffree(fp); } else { fp->f_data = (caddr_t)so; fp->f_flag = FREAD|FWRITE; fp->f_ops = &socketops; fp->f_type = DTYPE_SOCKET; p->p_retval[0] = fd; } return (error); } When it executes the sentence "p->p_retval[0] = fd", it changes the value returned by called, for example: int probe (){ int err; err = _sys_connect_socket(...); return (0); } The function probe() returns the value of fd in "p->p_retval[0] = fd" (3 or 4) and not zero. Thanks Yonny Cardenas B. ycardena@yahoo.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message