|  | pipe question. re-post from comp.unix.programming. |  | |
| | | Chad |  |
| Posted: Mon Aug 18, 2008 1:25 am Post subject: pipe question. re-post from comp.unix.programming. |  |
On page 502 in the book "Advanced Programming in the Unix Environment" by Stevens and Rago, they have a the following function to help sychronize the parent and child.
static int pfd1[2] , pfd2[2];
void TELL_PARENT(pid_t pid) { if (write(pfd2[1], "c", 1) != 1) err_sys("write error");
}
What's the point of using pid if the function TELL_PARENT() doesn't actually use it? I thought this might be some kind of error. However, I don't see any mention of it on the books website errata section. |
| |
| | | Chad |  |
| Posted: Mon Aug 18, 2008 1:46 am Post subject: Re: pipe question. re-post from comp.unix.programmer. |  |
On Aug 17, 6:25 pm, Chad <cdal...@gmail.com> wrote:
| Quote: | On page 502 in the book "Advanced Programming in the Unix Environment" by Stevens and Rago, they have a the following function to help sychronize the parent and child.
static int pfd1[2] , pfd2[2];
void TELL_PARENT(pid_t pid) { if (write(pfd2[1], "c", 1) != 1) err_sys("write error");
}
What's the point of using pid if the function TELL_PARENT() doesn't actually use it? I thought this might be some kind of error. However, I don't see any mention of it on the books website errata section. |
|
| |
| | | Jens Thoms Toerring |  |
| Posted: Mon Aug 18, 2008 5:08 pm Post subject: Re: pipe question. re-post from comp.unix.programming. |  |
| |  | |
Chad <cdalten@gmail.com> wrote:
| Quote: | On page 502 in the book "Advanced Programming in the Unix Environment" by Stevens and Rago, they have a the following function to help sychronize the parent and child.
static int pfd1[2] , pfd2[2];
void TELL_PARENT(pid_t pid) { if (write(pfd2[1], "c", 1) != 1) err_sys("write error");
}
What's the point of using pid if the function TELL_PARENT() doesn't actually use it? I thought this might be some kind of error. However, I don't see any mention of it on the books website errata section.
|
It looks a bit as if there are several different versions of the function in the example code, all with that name, but some needing the pid and others that don't. That makes me wonder if it's not actually meant this way so that programs that use the function can be linked with different object files with different versions of the function to make them behave in different ways. Then having the same prototype for all versions of the function would make a lot of sense. And since it's completely legal to pass stuff to a function that isn't actually needed I wouldn't expect it mentioned in the errata for the book. Regards, Jens -- \ Jens Thoms Toerring ___ jt@toerring.de \__________________________ LINK |
| |
|
|