LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-25-2012, 02:39 AM   #1
JeToMad
LQ Newbie
 
Registered: Mar 2012
Location: Valencia, Spain
Distribution: Fedora 15, Ubuntu 11.10
Posts: 15

Rep: Reputation: Disabled
A c program called from bash script stays defunct when killed


Greetings,

I have a small C program that creates a window (Using GTK+) and uses that window to play files using gstreamer. It plays some videos, and puts images between videos for a few seconds. Kind of media player, but very simple. Since I wanted it to be respawned if it failed (If some video is not found, for the moment, C program simply fails, respawns, and play the next file -Plays a list of movies-) I put the C program inside a while in a bash script. The bash script calls the C program, and when this exits, waits 5 seconds and respawns the program. Usually, this works like a charm. But I have found a problem, since with some videos I get some errors with MemMgr_Free. This seems to be a sign of memory leakage (Sorry if I am being terribly wrong, still a newbie with just windows experience). Well, point is, I tried to kill the process, since with this fault, program does not end, just freeze. But when I kill the program after this has happened, it stays "zombie" (Seems to be the usual word for defunct processes). Googling it points to the father as the one to blame, but... Since it works when C program behaves normally... I am not sure.

The machine running this program is far away, so I can only access via SSH. Any hint, pointers, anything else? As I have already said, I am just a windows newbie, and electronics engineer, not I.T. guy, so this scares me a lot. Specially when involving zombies

Oh, setup of the system:

Hardware: Pandaboard (I know that I should ask there, but does not seem to me as hardware-related)
Software: Ubuntu 11.10 (Kernel 3.1.0)

Lastly, cat /proc/meminfo shows "MemFree: 289664 kB", so the memory leakage (If it's that) has not left the system without any memory.

As with my other posts, please forgive the mistakes in the written text. Feel free to point anything that is wrongly said, as I am not english speaker, but always want to improve my skills.

Thanks in advance!
 
Old 04-25-2012, 02:57 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
usually it means your c code has died during a kernel call. So you need to kill the kernel to clean it up (that means a reboot). I can suggest you only to update/change/replace the player.
 
Old 04-25-2012, 03:02 AM   #3
JeToMad
LQ Newbie
 
Registered: Mar 2012
Location: Valencia, Spain
Distribution: Fedora 15, Ubuntu 11.10
Posts: 15

Original Poster
Rep: Reputation: Disabled
Well, the player is being written by me. So... If I understand you correctly, it is my code what causes the "defunct" status.

Since the code just creates the window, and then builds a gstreamer pipeline to play the videos, and this works ok with some videos and fails with others... May it be a codec issue? I don't know if codecs do kernel calls, but since this player uses hardware acceleration of the processor, probably this means that yes, that there are kernel calls.
 
Old 04-25-2012, 03:08 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
no, the real player is a codec somewhere inside gstreamer. All of the programs need the kernel, because all the resources available only by kernel calls. A user space app cannot access directly the hardware. So yes, it can be a codec issue.
 
1 members found this post helpful.
Old 04-25-2012, 03:12 AM   #5
JeToMad
LQ Newbie
 
Registered: Mar 2012
Location: Valencia, Spain
Distribution: Fedora 15, Ubuntu 11.10
Posts: 15

Original Poster
Rep: Reputation: Disabled
Ok, thank you very much.

Will ask at gstreamer mail-list.
 
Old 04-25-2012, 08:25 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Also remember what the "zombie" status is. When a process dies, it goes into "zombie" state specifically so that its parent can rendezvous with it and collect its final status without creating a race-condition. Only then does the process-table entry disappear. (If the parent dies, the children are parented to init (pid=1), "the one process that never dies," which reaps them.) Your parent script must reap its children.
 
  


Reply



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
Loading env into bash script called by cron grob115 Programming 1 03-18-2010 11:35 PM
can I determine if program is called from a specific php script ? odocoileus Programming 7 03-31-2009 07:29 AM
can expect be called from within a bash script? johnpaulodonnell Programming 4 06-21-2007 09:42 AM
Cannot create folders with bash script called from php keyF Linux - Software 4 06-25-2006 10:58 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration