-#ifdef L_xopendir
-// Die with an error message if opendir() fails.
-DIR *xopendir(const char *path)
-{
- DIR *dp;
-
- if ((dp = opendir(path)) == NULL)
- bb_perror_msg_and_die("unable to open `%s'", path);
- return dp;
-}
-#endif
-
-#ifdef L_xdaemon
-#ifndef BB_NOMMU
-// Die with an error message if we can't daemonize.
-void xdaemon(int nochdir, int noclose)
-{
- if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon");
-}
-#endif
-#endif
-
-#ifdef L_xsocket
-// Die with an error message if we can't open a new socket.
-int xsocket(int domain, int type, int protocol)
-{
- int r = socket(domain, type, protocol);
-
- if (r < 0) bb_perror_msg_and_die("socket");
-
- return r;
-}
-#endif
-
-#ifdef L_xbind
-// Die with an error message if we can't bind a socket to an address.
-void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
-{
- if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
-}
-#endif
-
-#ifdef L_xlisten
-// Die with an error message if we can't listen for connections on a socket.
-void xlisten(int s, int backlog)
-{
- if (listen(s, backlog)) bb_perror_msg_and_die("listen");
-}
-#endif
-
-#ifdef L_xstat
-// xstat() - a stat() which dies on failure with meaningful error message
-void xstat(char *name, struct stat *stat_buf)
-{
- if (stat(name, stat_buf))
- bb_perror_msg_and_die("can't stat '%s'", name);
-}
-#endif
-
-#ifdef L_get_terminal_width_height