aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-04-26 02:41:05 -0500
committerRob Landley <rob@landley.net>2013-04-26 02:41:05 -0500
commitf01534401412812bc1d904812dfb4b0a31ee8fff (patch)
treedb23ecd59e456f54cfd071eeca8806328e29b8d9 /lib/lib.c
parenta4a6dfb584a3de8c947d2ccf159b53bf56daebb7 (diff)
downloadtoybox-f01534401412812bc1d904812dfb4b0a31ee8fff.tar.gz
Add posix headers to toynet.h, move xioctl() to lib.c, introduce lib/net.c and move xsocket() to it.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 87ff12cb..4d8e23a4 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -739,6 +739,28 @@ char *xreadfile(char *name)
*/
+
+// Sleep for this many thousandths of a second
+void msleep(long miliseconds)
+{
+ struct timespec ts;
+
+ ts.tv_sec = miliseconds/1000;
+ ts.tv_nsec = (miliseconds%1000)*1000000;
+ nanosleep(&ts, &ts);
+}
+
+int xioctl(int fd, int request, void *data)
+{
+ int rc;
+
+ errno = 0;
+ rc = ioctl(fd, request, data);
+ if (rc == -1 && errno) perror_exit("ioctl %d", request);
+
+ return rc;
+}
+
// Open a /var/run/NAME.pid file, dying if we can't write it or if it currently
// exists and is this executable.
void xpidfile(char *name)