~ubuntu-branches/ubuntu/quantal/recoll/quantal

« back to all changes in this revision

Viewing changes to .pc/recoll_ionice_getpid.patch/utils/rclionice.cpp

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2012-04-04 12:16:48 UTC
  • Revision ID: package-import@ubuntu.com-20120404121648-ahic3utcetzt639f
Tags: 1.17.1-2
* debian/patches:
  + fix-kFreeBSD-ftbfs.patch: Added patch to fix FTBFS on kFreeBSD from
    upstream (Closes: #667083)
  + recoll_ionice_getpid.patch: Added patch to fix FTBFS with gcc-4.7 from
    upstream (Closes: #667352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2004 J.F.Dockes
 
2
 *   This program is free software; you can redistribute it and/or modify
 
3
 *   it under the terms of the GNU General Public License as published by
 
4
 *   the Free Software Foundation; either version 2 of the License, or
 
5
 *   (at your option) any later version.
 
6
 *
 
7
 *   This program is distributed in the hope that it will be useful,
 
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
 *   GNU General Public License for more details.
 
11
 *
 
12
 *   You should have received a copy of the GNU General Public License
 
13
 *   along with this program; if not, write to the
 
14
 *   Free Software Foundation, Inc.,
 
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
16
 */
 
17
#include <stdio.h>
 
18
 
 
19
#include "rclionice.h"
 
20
#include "execmd.h"
 
21
#include "debuglog.h"
 
22
 
 
23
bool rclionice(const string& clss, const string& cdata)
 
24
{
 
25
    string ionicexe;
 
26
    if (!ExecCmd::which("ionice", ionicexe)) {
 
27
        // ionice not found, bail out
 
28
        LOGDEB0(("rclionice: ionice not found\n"));
 
29
        return false;
 
30
    }
 
31
    list<string> args;
 
32
    args.push_back("-c");
 
33
    args.push_back(clss);
 
34
 
 
35
    if (!cdata.empty()) {
 
36
        args.push_back("-n");
 
37
        args.push_back(cdata);
 
38
    }
 
39
    
 
40
    char cpid[100];
 
41
    sprintf(cpid, "%d", getpid());
 
42
    args.push_back("-p");
 
43
    args.push_back(cpid);
 
44
 
 
45
    ExecCmd cmd;
 
46
    int status = cmd.doexec(ionicexe, args);
 
47
 
 
48
    if (status) {
 
49
        LOGERR(("rclionice: failed, status 0x%x\n", status));
 
50
        return false;
 
51
    }
 
52
    return true;
 
53
}