aboutsummaryrefslogtreecommitdiff
path: root/libbb/xfuncs.c
diff options
context:
space:
mode:
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 870d736b3..7fe5c3a45 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -557,6 +557,22 @@ void xlisten(int s, int backlog)
557 if (listen(s, backlog)) bb_perror_msg_and_die("listen"); 557 if (listen(s, backlog)) bb_perror_msg_and_die("listen");
558} 558}
559 559
560/* Die with an error message if we the sendto failed.
561 * Return bytes sent otherwise
562 */
563
564ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
565 socklen_t tolen)
566{
567 ssize_t ret = sendto(s, buf, len, 0, to, tolen);
568 if (ret < 0) {
569 if (ENABLE_FEATURE_CLEAN_UP)
570 close(s);
571 bb_perror_msg_and_die("sendto");
572 }
573 return ret;
574}
575
560// xstat() - a stat() which dies on failure with meaningful error message 576// xstat() - a stat() which dies on failure with meaningful error message
561void xstat(const char *name, struct stat *stat_buf) 577void xstat(const char *name, struct stat *stat_buf)
562{ 578{