aboutsummaryrefslogtreecommitdiffstats
path: root/src/slack.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-09-23 00:47:43 +0200
committerMattias Andrée <maandree@operamail.com>2014-09-23 00:47:43 +0200
commit7eeb55d56464e29f6b804edca33fec4131ba3976 (patch)
tree20464718fc83eecb4c199e33595e171afbc815d9 /src/slack.c
parentdoes not affect real-time processes (diff)
downloadslack-7eeb55d56464e29f6b804edca33fec4131ba3976.tar.gz
slack-7eeb55d56464e29f6b804edca33fec4131ba3976.tar.bz2
slack-7eeb55d56464e29f6b804edca33fec4131ba3976.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/slack.c')
-rw-r--r--src/slack.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/slack.c b/src/slack.c
index bd9e6b1..31330db 100644
--- a/src/slack.c
+++ b/src/slack.c
@@ -15,9 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -25,6 +22,13 @@
#include <sys/prctl.h>
+
+#define NS (1L)
+#define US (1000L)
+#define MS (1000L * 1000L)
+#define S (1000L * 1000L * 1000L)
+
+
static void usage(void)
{
printf("USAGE: slack (get | GET | (reset | <interval> <options..> [--fatal] [--] <command..>))\n");
@@ -48,14 +52,6 @@ static void usage(void)
}
-
-#define NS (1L)
-#define US (1000L)
-#define MS (1000L * 1000L)
-#define S (1000L * 1000L * 1000L)
-
-
-
int main(int argc, char** argv)
{
long slackvalue, r;
@@ -114,7 +110,7 @@ int main(int argc, char** argv)
slackvalue = strtol(argv[1], &end, 10);
if (end == argv[1])
- return fprintf(stderr, "No slack value specified."), 1;
+ return fprintf(stderr, "No slack value specified."), free(exec_argv), 1;
if (!strcmp(end, "n") || !strcmp(end, "ns") || !strcmp(end, "")) slackvalue *= NS;
else if (!strcmp(end, "µ") || !strcmp(end, "µs")) slackvalue *= US;
@@ -122,18 +118,19 @@ int main(int argc, char** argv)
else if (!strcmp(end, "m") || !strcmp(end, "ms")) slackvalue *= MS;
else if (!strcmp(end, "s")) slackvalue *= S;
else
- return fprintf(stderr, "Unrecognised suffix for slack value."), 1;
+ return fprintf(stderr, "Unrecognised suffix for slack value."), free(exec_argv), 1;
if (slackvalue <= 0)
- return fprintf(stderr, "Invalid slack value: %lins", slackvalue), 1;
+ return fprintf(stderr, "Invalid slack value: %lins", slackvalue), free(exec_argv), 1;
}
if (r = prctl(PR_SET_TIMERSLACK, slackvalue), r < 0)
if (perror(*argv), fatal)
- return 2;
+ return free(exec_argv), 2;
execvp(*exec_argv, exec_argv);
perror(*argv);
+ free(exec_argv);
return 2;
}