aboutsummaryrefslogtreecommitdiff
path: root/tests/server/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/server/util.c')
-rw-r--r--tests/server/util.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/server/util.c b/tests/server/util.c
index 65d491c0b..169ca5bcb 100644
--- a/tests/server/util.c
+++ b/tests/server/util.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -284,6 +284,20 @@ int write_pidfile(const char *filename)
return 1; /* success */
}
+/* store the used port number in a file */
+int write_portfile(const char *filename, int port)
+{
+ FILE *portfile = fopen(filename, "wb");
+ if(!portfile) {
+ logmsg("Couldn't write port file: %s %s", filename, strerror(errno));
+ return 0; /* fail */
+ }
+ fprintf(portfile, "%d\n", port);
+ fclose(portfile);
+ logmsg("Wrote port %d to %s", port, filename);
+ return 1; /* success */
+}
+
void set_advisor_read_lock(const char *filename)
{
FILE *lockfile;