Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-04-2003, 02:17 PM   #1
LQ Newbie
Registered: Jan 2003
Posts: 11

Rep: Reputation: 0
Servlets executing a C program.

Hi: I have a website(servlets on Apache/Tomcat/mysql ) that does the following.

Lets user upload a file, gives this file as input to a C program. The C program exectutes and gives some output files. The servlet picks up those output files and lists them to user for downloading/viewing.

Problems I have now:
1. Where to store the C program- I have put it in /tomcat/bin for now. If I have it anywhere else, it gives me a segmentation fault or Access Denied(dont know why) The file owner is root. Now is this safe?

2. After a period of inactivity(generally overnight) my servlet gives this exception "./myCcode: No such file or directroy" . If I restart the server this error disappears.

3. Sometimes the c code gives me a core dump for a particular file. Once again restarting the server makes this disappear.

4. I call the c code either directly from the servlet or in the background as a thread(depending on if the user wants the result sent to him as an email). Now for the same uploaded file, the direct servlet execution works ok while if its a background thread I get a core dump. Again restarting the server makes this behavior disappear.

I use the Runtime.exec() method to execute the c code. If anybody can solve any or all of the above mysteries(to me) I would really appreciate it.
Actually I have another c program with similar functions as the first one on my website, and it has NEVER given me any of the above problems. This was written by another programmer, which makes me wonder if its the c program which is faulty?!!!

Thanks a lot for any input.

Last edited by webee; 02-04-2003 at 02:20 PM.
Old 02-04-2003, 05:19 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I would think that there's a problem with your C code if you get
segfaults on a more or less regular basis ...

As for the way you call it, I'd recommend you try this ...



Last edited by Tinkster; 02-04-2003 at 05:22 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing program as non-root arip Programming 4 12-01-2005 05:41 AM
executing a program as root funkymunky Linux - General 2 05-06-2005 12:48 PM
How executing c program with php? payal_shah Programming 6 04-08-2005 10:44 PM
executing a program in new terminal? kashifbilal Programming 7 04-26-2004 04:52 AM
Executing a program with out system() in c++ sobdk Programming 2 11-02-2002 07:45 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration