LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 11-09-2010, 01:47 AM   #1
wang_zijian
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Rep: Reputation: 0
ask for hell: program started from shell is killed by linux automatically


Hi,
I am writing a c code for a embedded system
cpu: arm
os: linux

I worte a socket program, which works as follows:
1. bind to port
2. listen
3. receive new connection
4. start new thread to process the packet received from new connection

If I start this program in terminal, it works fine
Then I wrote a shell, as follows:
shell (1)
if [ -e program_start ]
then
echo "program started"
else
/XX/XX/myprogram &
touch program_start
fi

if I run the shell in terminal, the program works fine.
But if I put the shell in crontab, reboot the system, and let the cron to start the shell, the program will start and work for some time, then it will be killed automacically.

In order to make sure the program is running, I worte another shell, as follows
shell (2)
while true
check program is running
if not
restart
sleep 1

shell (2)is call in shell (1) (jsut replace "/XX/XX/myprogram &" with "/XX/XX/shell (2)")

It will restart the program but there are few seconds the program is not running.

I do not know why the program is killed by linux if it is started by shell (called by linux itself(crontab)).

Please help me out.

Thanks.

Zijian Wang

Last edited by wang_zijian; 11-09-2010 at 02:06 AM.
 
Old 11-09-2010, 05:07 AM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,094
Blog Entries: 2

Rep: Reputation: 111Reputation: 111
Well potential automatic kills are it has a bug causing a segfault, bus error, div by zero, ... or it triggers the memory hog kill by sucking up all the available ram
 
Old 11-09-2010, 08:07 PM   #3
wang_zijian
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, estabroo
It is strange that the program works fine if it is started from terminal. But if it is started from shell called by linux, the program will run for some time and killed.
 
Old 11-10-2010, 05:00 AM   #4
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,094
Blog Entries: 2

Rep: Reputation: 111Reputation: 111
I'm guessing it'll die running from the terminal as well, just takes a while. A thing to try is to fire it up inside a screen and then see if you get any output for the reason it does get killed.


screen
run your program
Ctrl-A d to detach from screen

when it dies later, reattach to that screen and see the results, if any
screen -r
 
Old 11-11-2010, 01:03 AM   #5
wang_zijian
LQ Newbie
 
Registered: Nov 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, estabroo
I run the program from terminal, after a whole night, it is ok. But if it is started from shell call by crontab, it will work for 3-10 min (not the same for each time) and then be killed.
Is this related to crontab?
I tried to export PATH, LD_LIBARARY_PATH at the begining of shell, but it does not change anything.
The wired thing is that it can be started by shell called by crontab (somebody said that their shell can not be started by contab), but it is killed from some reason. But it can work for very long time if it is started from terminal by hand.
 
Old 11-11-2010, 05:12 AM   #6
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,094
Blog Entries: 2

Rep: Reputation: 111Reputation: 111
That is very bizarre. Running it via cron shouldn't cause it to be killed, cron just fires it off. Guess you'll need to add some logging to the program either prints/echos or syslog (if prints/echos use stderr and redirect the output to a file) to find out what it is doing when it dies.
 
  


Reply


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
Automatically restart killed process i_nomad Red Hat 2 10-27-2008 07:56 AM
LXer: Linux automatically monitor and restart services when daemon is killed LXer Syndicated Linux News 0 11-25-2006 10:21 PM
X screwey on startup, fine after killed & started again 95se Linux - Laptop and Netbook 0 11-18-2006 12:27 PM
Adobe reader being killed automatically, why??? TruongAn Linux - Software 3 11-16-2005 01:17 AM
process is getting killed automatically chens_83 Linux - General 2 09-16-2002 03:52 AM


All times are GMT -5. The time now is 03:39 AM.

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