fail running an external C program into a Perl CGI script

Discussion in 'Perl Misc' started by yairl@savion.huji.ac.il, Dec 30, 2008.

  1. Guest

    hi,

    I 'm trying to execute a small C program into the Perl CGI working
    with apache server and it fail . I used `cmd` , sytem, qx( ) , open
    orders every thing it doens't work when it run as CGI. The script
    works fine if it runs as shell script by hand or cron but the forked
    program send "segmentation fault" and it ended with status 35584
    (ACCESS VIOLATION) when it runs into CGI mode under apache server or
    Sun One webserver. This happened with some C small programs they use
    socket to connect some resources outside and return some value to
    evaluate. These programs started to fail since perl 5.6 under linux
    SuSe 9 ,10 and solaris 8 and 9. The regular OS orders like date, cat ,
    cal work fine, I tested it. I don't understand why is happened, what's
    wrong they are common C progrmas using the standard C library like
    socket lib. Someone know anything about this bug?
    , Dec 30, 2008
    #1
    1. Advertising

  2. smallpond Guest

    On Dec 30, 4:59 am, wrote:
    > hi,
    >
    > I 'm trying to execute a small C program into the Perl CGI working
    > with apache server and it fail . I used `cmd` , sytem, qx( ) , open
    > orders every thing it doens't work when it run as CGI. The script
    > works fine if it runs as shell script by hand or cron but the forked
    > program send "segmentation fault" and it ended with status 35584
    > (ACCESS VIOLATION) when it runs into CGI mode under apache server or
    > Sun One webserver. This happened with some C small programs they use
    > socket to connect some resources outside and return some value to
    > evaluate. These programs started to fail since perl 5.6 under linux
    > SuSe 9 ,10 and solaris 8 and 9. The regular OS orders like date, cat ,
    > cal work fine, I tested it. I don't understand why is happened, what's
    > wrong they are common C progrmas using the standard C library like
    > socket lib. Someone know anything about this bug?



    Most likely you are trying to execute a program in a directory
    or as a user that does not have proper permission. This is
    more likely an apache problem than perl. Check httpd.conf.
    smallpond, Dec 30, 2008
    #2
    1. Advertising

  3. wrote:
    >I 'm trying to execute a small C program into the Perl CGI working
    >with apache server and it fail . I used `cmd` , sytem, qx( ) , open
    >orders every thing it doens't work when it run as CGI. The script
    >works fine if it runs as shell script by hand or cron but the forked
    >program send "segmentation fault" and it ended with status 35584
    >(ACCESS VIOLATION) when it runs into CGI mode under apache server or
    >Sun One webserver.


    You have a close cousin to "Server error 500", see "perldoc -q 500" for
    details.

    jue
    Jürgen Exner, Dec 30, 2008
    #3
  4. smallpond Guest

    On Dec 30, 8:54 am, Jürgen Exner <> wrote:
    > wrote:
    > >I 'm trying to execute a small C program into the Perl CGI working
    > >with apache server and it fail . I used `cmd` , sytem, qx( ) , open
    > >orders every thing it doens't work when it run as CGI. The script
    > >works fine if it runs as shell script by hand or cron but the forked
    > >program send "segmentation fault" and it ended with status 35584
    > >(ACCESS VIOLATION) when it runs into CGI mode under apache server or
    > >Sun One webserver.

    >
    > You have a close cousin to "Server error 500", see "perldoc -q 500" for
    > details.
    >
    > jue


    My mistake. Based on the FAQ, I was not supposed to give a polite
    answer.
    smallpond, Dec 30, 2008
    #4
  5. Tim Greer Guest

    smallpond wrote:

    > My mistake.  Based on the FAQ, I was not supposed to give a polite
    > answer.


    That made me laugh. Thanks.
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Dec 30, 2008
    #5
  6. Tim Greer Guest

    wrote:

    > hi,
    >
    > I 'm trying to execute a small C program into the Perl CGI working
    > with apache server and it fail . I used `cmd` , sytem, qx( ) , open
    > orders every thing it doens't work when it run as CGI. The script
    > works fine if it runs as shell script by hand or cron but the forked
    > program send "segmentation fault" and it ended with status 35584
    > (ACCESS VIOLATION) when it runs into CGI mode under apache server or
    > Sun One webserver. This happened with some C small programs they use
    > socket to connect some resources outside and return some value to
    > evaluate. These programs started to fail since perl 5.6 under linux
    > SuSe 9 ,10 and solaris 8 and 9. The regular OS orders like date, cat ,
    > cal work fine, I tested it. I don't understand why is happened, what's
    > wrong they are common C progrmas using the standard C library like
    > socket lib. Someone know anything about this bug?


    Are you using a script or program that's suid/sgid, or running SuEXEC
    for CGI? This doesn't sound like a Perl issue, as others have said.
    --
    Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
    Industry's most experienced staff! -- Web Hosting With Muscle!
    Tim Greer, Dec 30, 2008
    #6
  7. Guest

    On Dec 30, 8:53 pm, Tim Greer <> wrote:
    > wrote:
    > > hi,

    >
    > > I 'm trying to execute a small C program into the Perl CGI working
    > > with apache server and it fail . I used `cmd` , sytem, qx( ) , open
    > > orders every thing it doens't work when it run as CGI. The script
    > > works fine if it runs as shell script by hand or cron but the forked
    > > program send "segmentation fault" and it ended with status 35584
    > > (ACCESS VIOLATION) when it runs into CGI mode under apache server or
    > > Sun One webserver. This happened with some C small programs they use
    > > socket to connect some resources outside and return some value to
    > > evaluate. These programs started to fail since perl 5.6 under linux
    > > SuSe 9 ,10 and solaris 8 and 9. The regular OS orders like date, cat ,
    > > cal work fine, I tested it. I don't understand why is happened, what's
    > > wrong they are common C progrmas using the standard C library like
    > > socket lib. Someone know anything about this bug?

    >
    > Are you using a script or program that's suid/sgid, or running SuEXEC
    > for CGI?  This doesn't sound like a Perl issue, as others have said.
    > --
    > Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
    > Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
    > and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
    > Industry's most experienced staff! -- Web Hosting With Muscle!- Hide quoted text -
    >
    > - Show quoted text -


    first thanks to everybody that answered.
    It's a common CGI script running into cgi-bin. I don't think it's a
    permition problem because i can execute shell orders. It's something
    into these C programs that it doesn't work correctly in the webserver
    enviroment.
    I read some post in this forum talking about the output buffering
    problem, it sound me that may be the point. I'm going to test the
    Expect module and check if it solve the problem. Anyway if the Expect
    module doesn't work I decided to rewrite this program in perl as perl
    module. I did it before with others small C programs that stoped to
    work.
    , Dec 31, 2008
    #7
  8. Kiss Gabor Guest

    In article <>,
    writes:
    >> > I 'm trying to execute a small C program into the Perl CGI working
    >> > with apache server and it fail . I used `cmd` , sytem, qx( ) , open


    > first thanks to everybody that answered.
    > It's a common CGI script running into cgi-bin. I don't think it's a
    > permition problem because i can execute shell orders. It's something
    > into these C programs that it doesn't work correctly in the webserver
    > enviroment.


    Why don't you trace apache processes and their children?

    Gabor
    Kiss Gabor, Dec 31, 2008
    #8
  9. Guest

    On Dec 31, 11:17 am, (Kiss Gabor) wrote:
    > In article <..com>,
    >         writes:
    >
    > >> > I 'm trying to execute a small C program into the Perl CGI working
    > >> > with apache server and it fail . I used `cmd` , sytem, qx( ) , open

    > > first thanks to everybody that answered.
    > > It's a common CGI script running into cgi-bin. I don't think it's a
    > > permition problem because i can execute shell orders. It's something
    > > into these C programs that it doesn't work correctly in the webserver
    > > enviroment.

    >
    > Why don't you trace apache processes and their children?
    >
    > Gabor


    I did more debug and i found that the C program running into the CGI
    under the webserver user can't read or use the socket then it produce
    a null pointer and crash. The script works only under root privileges,
    i don't understand how before worked and now not. The problem is
    connected to permitions to use sockets. i don't have more time to
    waste with it then we'll write a perl module for this task, always
    modules work fine...
    , Dec 31, 2008
    #9
  10. Kiss Gabor Guest

    In article <>,
    writes:
    > I did more debug and i found that the C program running into the CGI
    > under the webserver user can't read or use the socket then it produce
    > a null pointer and crash. The script works only under root privileges,


    Eeeeer.... you should always check return value of library functions.

    Gabor
    Kiss Gabor, Dec 31, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jürgen Exner

    Re: CGI Perl "use CGI" statement fail

    Jürgen Exner, Jul 31, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,227
    Jürgen Exner
    Jul 31, 2003
  2. Replies:
    20
    Views:
    671
    Gunnar Hjalmarsson
    Jan 18, 2005
  3. kath
    Replies:
    4
    Views:
    537
    J. Gleixner
    Apr 9, 2007
  4. Replies:
    4
    Views:
    287
    ccc31807
    Jul 29, 2011
  5. lovecreatesbeauty
    Replies:
    2
    Views:
    357
    lovecreatesbeauty
    Jul 20, 2011
Loading...

Share This Page