diff --git a/examples/libevent-client.c b/examples/libevent-client.c index 92b82135..7c3e0c90 100644 --- a/examples/libevent-client.c +++ b/examples/libevent-client.c @@ -22,6 +22,17 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifdef __sgi +#include +#define errx(exitcode, format, args...) \ + { \ + warnx(format, ##args); \ + exit(exitcode); \ + } +#define warnx(format, args...) fprintf(stderr, format "\n", ##args) +char *strndup(const char *s, size_t size); +#endif + #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ @@ -37,7 +48,9 @@ #include #endif /* HAVE_NETINET_IN_H */ #include +#ifndef __sgi #include +#endif #include #include diff --git a/examples/libevent-server.c b/examples/libevent-server.c index 381977dd..21b20c3f 100644 --- a/examples/libevent-server.c +++ b/examples/libevent-server.c @@ -22,6 +22,16 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifdef __sgi +#define errx(exitcode, format, args...) \ + { \ + warnx(format, ##args); \ + exit(exitcode); \ + } +#define warn(format, args...) warnx(format ": %s", ##args, strerror(errno)) +#define warnx(format, args...) fprintf(stderr, format "\n", ##args) +#endif + #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ @@ -46,7 +56,9 @@ #include #endif /* HAVE_NETINET_IN_H */ #include +#ifndef __sgi #include +#endif #include #include @@ -672,7 +684,7 @@ static void start_listen(struct event_base *evbase, const char *service, rv = getaddrinfo(NULL, service, &hints, &res); if (rv != 0) { - errx(1, NULL); + errx(1, "Could not resolve server address"); } for (rp = res; rp; rp = rp->ai_next) { struct evconnlistener *listener; diff --git a/src/nghttpd.cc b/src/nghttpd.cc index 0e7e63c4..e5d7c2e0 100644 --- a/src/nghttpd.cc +++ b/src/nghttpd.cc @@ -24,6 +24,10 @@ */ #include "nghttp2_config.h" +#ifdef __sgi +#define daemon _daemonize +#endif + #ifdef HAVE_UNISTD_H #include #endif // HAVE_UNISTD_H @@ -352,7 +356,11 @@ int main(int argc, char **argv) { std::cerr << "-d option must be specified when -D is used." << std::endl; exit(EXIT_FAILURE); } +#ifdef __sgi + if (daemon(0, 0, 0, 0) == -1) { +#else if (daemon(0, 0) == -1) { +#endif perror("daemon"); exit(EXIT_FAILURE); }