Date: Mon, 26 Feb 2001 10:37:32 -0500 From: "Yonny Cardenas B." <ycardena@yahoo.com> To: questions@freebsd.org Subject: proc struct changes the value returned by return() Message-ID: <3A9A783C.86B67887@yahoo.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A9A783C.86B67887>
