diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /src/pmsleep | |
download | pcp-47e6e7c84f008a53061e661f31ae96629bc694ef.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'src/pmsleep')
-rw-r--r-- | src/pmsleep/GNUmakefile | 32 | ||||
-rw-r--r-- | src/pmsleep/pmsleep.c | 43 |
2 files changed, 75 insertions, 0 deletions
diff --git a/src/pmsleep/GNUmakefile b/src/pmsleep/GNUmakefile new file mode 100644 index 0000000..4682093 --- /dev/null +++ b/src/pmsleep/GNUmakefile @@ -0,0 +1,32 @@ +# +# Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# + +TOPDIR = ../.. +include $(TOPDIR)/src/include/builddefs + +LLDLIBS = $(PCPLIB) +CFILES = pmsleep.c +CMDTARGET = pmsleep$(EXECSUFFIX) +LDIRT = $(TARGET) + +default: $(CMDTARGET) + +include $(BUILDRULES) + +install: $(CMDTARGET) + $(INSTALL) -m 755 $(CMDTARGET) $(PCP_BINADM_DIR)/$(CMDTARGET) + +default_pcp: default + +install_pcp: install diff --git a/src/pmsleep/pmsleep.c b/src/pmsleep/pmsleep.c new file mode 100644 index 0000000..a3c5f75 --- /dev/null +++ b/src/pmsleep/pmsleep.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include "pmapi.h" + +int +main(int argc, char **argv) +{ + struct timespec rqt; + struct timeval delta; + int r = 0; + char *msg; + + if (argc == 2) { + if (pmParseInterval(argv[1], &delta, &msg) < 0) { + fputs(msg, stderr); + free(msg); + } else { + rqt.tv_sec = delta.tv_sec; + rqt.tv_nsec = delta.tv_usec * 1000; + if (0 != nanosleep(&rqt, NULL)) + r = oserror(); + + exit(r); + } + } + fprintf(stderr, "Usage: pmsleep interval\n"); + exit(1); +} |