* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <config.h>
#include <libtest/common.h>
using namespace libtest;
#include <cstdlib>
#include <cstring>
+#include <cerrno>
#include <fcntl.h>
#include <fstream>
#include <memory>
if (spawn_ret)
{
- Error << print();
return Application::INVALID;
}
close(WRITE);
int ret;
- if ((ret= pipe(_fd)) < 0)
+ if (pipe(_fd) == -1)
{
- throw strerror(ret);
+ throw strerror(errno);
}
_open[0]= true;
_open[1]= true;
{
- ret= fcntl(_fd[0], F_GETFL, 0);
- if (ret == -1)
+ if ((ret= fcntl(_fd[0], F_GETFL, 0)) == -1)
{
- Error << "fcntl(F_GETFL) " << strerror(ret);
- throw strerror(ret);
+ Error << "fcntl(F_GETFL) " << strerror(errno);
+ throw strerror(errno);
}
- ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK);
- if (ret == -1)
+ if ((ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK)) == -1)
{
- Error << "fcntl(F_SETFL) " << strerror(ret);
- throw strerror(ret);
+ Error << "fcntl(F_SETFL) " << strerror(errno);
+ throw strerror(errno);
}
}
}
if (_open[type])
{
int ret;
- if ((ret= ::close(_fd[type])) < 0)
+ if (::close(_fd[type]) == -1)
{
- Error << "close(" << strerror(ret) << ")";
+ Error << "close(" << strerror(errno) << ")";
}
_open[type]= false;
+ _fd[type]= -1;
}
}
void Application::delete_argv()
{
- if (built_argv == NULL)
- {
- return;
- }
-
- for (size_t x= 0; x < _argc; x++)
+ if (built_argv)
{
- if (built_argv[x])
+ for (size_t x= 0; x < _argc; x++)
{
- ::free(built_argv[x]);
+ if (built_argv[x])
+ {
+ ::free(built_argv[x]);
+ }
}
+ delete[] built_argv;
+ built_argv= NULL;
+ _argc= 0;
}
- delete[] built_argv;
- built_argv= NULL;
- _argc= 0;
}