3
MediaTomb - http://www.mediatomb.cc/
5
process_executor.cc - this file is part of MediaTomb.
7
Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
10
Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
11
Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
Leonhard Wimmer <leo@mediatomb.cc>
14
MediaTomb is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License version 2
16
as published by the Free Software Foundation.
18
MediaTomb is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
23
You should have received a copy of the GNU General Public License
24
version 2 along with MediaTomb; if not, write to the Free Software
25
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
27
$Id: process_executor.cc 1698 2008-02-23 20:48:30Z lww $
30
/// \file process_executor.cc
33
#include "autoconfig.h"
36
#include "process_executor.h"
43
ProcessExecutor::ProcessExecutor(String command, Ref<Array<StringBase> > arglist)
48
argv[0] = command.c_str();
51
for (int i = 0; i < arglist->size(); i++)
53
argv[++apos] = arglist->get(i)->data;
54
if (apos >= MAX_ARGS-1)
66
throw _Exception(_("Failed to launch process ") + command);
70
pthread_sigmask(SIG_SETMASK, &mask_set, NULL);
71
log_debug("Launching process: %s\n", command.c_str());
72
execvp(command.c_str(), argv);
77
log_debug("Launched process %s, pid: %d\n", command.c_str(), process_id);
80
bool ProcessExecutor::isAlive()
82
return is_alive(process_id, &exit_status);
85
bool ProcessExecutor::kill()
87
return kill_proc(process_id);
90
int ProcessExecutor::getStatus()
92
is_alive(process_id, &exit_status);
96
ProcessExecutor::~ProcessExecutor()