in reply to Re^2: communication between C and perl
in thread communication between C and perl

When I run your example I get
~/tmp/cperl> ./a.out FIFO was successfully made! Segmentation fault
I get the segmentation fault (from the c program) when I start the perl script :(

Anyway, what is so different about this approach and simply using the number 63 ?

LuCa

Replies are listed 'Best First'.
Re^4: communication between C and perl
by zentara (Cardinal) on Feb 09, 2007 at 16:36 UTC
    Yeah, thats weird. I probably cheated on the way line is defined, and my compiler automagically fixed it. Instead of
    char *line; /* try */ char line[256];
    C is very finicky about allocating space for strings, and will segfault without telling why. This is one of the primary reasons people like Perl over C.

    Try this free book: Advanced Linux Programming and read the chapter on IPC.

    The difference between my script and your's using &63, is that mine uses a named-pipe which can be accessed by different process. Using &63, you are using a shared filehandle referenced by it's fileno, and requires that both scripts share them..... that means 1 script must fork off the other, instead of them being started separately. Of course, I'm not an expert c programmer, so take that with a grain of salt. This isn't the place to discuss c anyways.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      thnx, it works!