summaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2007-04-12 11:34:39 +0000
committerBernhard Reutner-Fischer2007-04-12 11:34:39 +0000
commitb290889f0265e1278e8a868aa82a65bcc9099b0f (patch)
tree2fc8dcc3b7f525f61817417e32c2827b57e17b8a /libbb/xfuncs.c
parent51742f4bb0c57a4d5063ece9437a2f34a42e52c8 (diff)
downloadbusybox-b290889f0265e1278e8a868aa82a65bcc9099b0f.zip
busybox-b290889f0265e1278e8a868aa82a65bcc9099b0f.tar.gz
- add xsendto and use where appropriate; shrink iplink; sanitize libiproute a bit.
-916 byte
Diffstat (limited to 'libbb/xfuncs.c')
-rw-r--r--libbb/xfuncs.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 870d736..7fe5c3a 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -557,6 +557,22 @@ void xlisten(int s, int backlog)
if (listen(s, backlog)) bb_perror_msg_and_die("listen");
}
+/* Die with an error message if we the sendto failed.
+ * Return bytes sent otherwise
+ */
+
+ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
+ socklen_t tolen)
+{
+ ssize_t ret = sendto(s, buf, len, 0, to, tolen);
+ if (ret < 0) {
+ if (ENABLE_FEATURE_CLEAN_UP)
+ close(s);
+ bb_perror_msg_and_die("sendto");
+ }
+ return ret;
+}
+
// xstat() - a stat() which dies on failure with meaningful error message
void xstat(const char *name, struct stat *stat_buf)
{