Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Programming

pipe question. re-post from comp.unix.programming.

 
Jump to:  
 
Chad
PostPosted: 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
PostPosted: 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
PostPosted: 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
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

miami auto auction opony ciężarowe prowadnice Ustawa o utrzymaniu czystości i porządku w gminach Tanie Hotele Chorzów