LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 11-15-2009, 05:46 PM   #1
ajb181
LQ Newbie
 
Registered: Sep 2009
Posts: 8

Rep: Reputation: 0
Kill child process problem. No matter what i try cant stop pid becoming a zombie??


I am trying to Kill a child task and i can not do it without it becomming a zombie.

This is on an embedded platform and the Child process is running MPG321 with the execvp() command.

I tryed everything i could find on the net with no luck. If you could help with this problem and my understanding of why this is occuring that would be most appreciated. Have been stuck with this problem for some months now..

when killing task i get the error number 10 which i think is #define ECHILD 10 /* No child processes */ But i have checked that i am sending kill the correct PID number.??


this is the calling task

Code:
				/* Create the pipe. */
				if (pipe(inst->_info_pipe))
				{
					//__SERVERDBG("MP3: Pipe failed");
					__EXCEPT(EXCEPTION_APPLICATION);
				}

				/* Create the child process. */

				frk_pid = fork ();

				if (frk_pid == (pid_t) 0)
				{
					/* This is the child process. */
					dup2(inst->_info_pipe[1],2);
					close(inst->_info_pipe[0]);
					inst->_SongLen = 0;

					/* set the group (session) id to this process for future killing */
				setsid();


					execvp(exec_bin,cmd_ptr);


					exit(0);
				}

//parent reading from pipe
	inst->_main_thread = frk_pid;

					close(inst->_info_pipe[1]);
					inst->_info_pipe[1] = -1;

					inst->_current_state = PLAYING;

					int retrys = 0;

					while(inst->_current_state == PLAYING) // wont return from here till song is finished
					{
						char Tmp[50];

						int r = read(inst->_info_pipe[0], Tmp,50);

						if(r > 0)
						{
							retrys = 0;
							inst->ParseOutput(Tmp, r);
						}
						else
						{
							retrys++;
							if(retrys == 2)
							{
								__SERVERDBG("retrys");
								//inst->StopPlayerApp();
								//inst->_current_state = STOPPED;
								break;
							}

							if(inst->_current_state != PLAYING)
							{
								__SERVERDBG("No longer playing");
							}
						}
					}

					inst->FlushParser();

//Kill function
void MP3Controller::StopPlayerApp()
{
	pid_t t = 0;

	if(_main_thread == -1) // not thread running
		return;

	//Stop player

	/*if (killpg(_main_thread, SIGINT) == -1)
	{
	//	os::sleep(100);
		//kill(-_main_thread, 2);
	}*/

	int killReturn = killpg(_main_thread, SIGINT) ;

	if( killReturn == ESRCH)      // pid does not exist
	{
		__SERVERDBG("Group does not exist!");
	}
	else if( killReturn == EPERM) // No permission to send signal
	{
		  __SERVERDBG("No permission to send signal!");
	}
	else
		__SERVERDBG("No problem sending sig!");

	int childExitStatus;

	t = waitpid (_main_thread, &childExitStatus, WNOHANG);

	if (t != _main_thread)
	{
		__SERVERDBG("error %i" , errno);
	//	waitpid (_main_thread, NULL, 0);
	}

	_main_thread = -1;

	// Close pipes
    close(_info_pipe[0]); // shut pipe from MP3 app
    _info_pipe[0] = -1;

    FlushParser();
}

Last edited by ajb181; 11-15-2009 at 05:51 PM. Reason: more info
 
Old 11-15-2009, 06:36 PM   #2
AuroraZero
Member
 
Registered: Oct 2009
Location: Michigan
Distribution: SlackWare 13.37, Android, Slax, Centos 5.9 Final, Centos 6
Posts: 187

Rep: Reputation: 31
What version of linux is this? Is there a way you can change your keyboard layout so that when you press ctrl+alt+del it give you all the running processes so you can make sure you are calling and killing the right pid?
 
  


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
how to kill zombie process bharatlalgupta Red Hat 1 06-18-2009 11:17 AM
How to get the PID of the process giving kill signal to a process? hariprd Programming 2 11-27-2008 04:10 AM
How to kill a Child and all its subsequent child process in C shayer009 Programming 3 12-04-2007 01:40 AM
how to kill zombie process mokku Linux - Server 5 10-25-2007 10:21 PM
get the PID of a separate process (no parent-child relationship) arunj Linux - Software 6 02-03-2006 02:50 AM


All times are GMT -5. The time now is 11:07 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration