diff options
Diffstat (limited to 'tests/bugs/cli/bug-1169302.c')
-rw-r--r-- | tests/bugs/cli/bug-1169302.c | 127 |
1 files changed, 64 insertions, 63 deletions
diff --git a/tests/bugs/cli/bug-1169302.c b/tests/bugs/cli/bug-1169302.c index aa9f950abf2..7c6b5fbf856 100644 --- a/tests/bugs/cli/bug-1169302.c +++ b/tests/bugs/cli/bug-1169302.c @@ -7,72 +7,73 @@ int keep_running = 1; -void stop_running(int sig) +void +stop_running(int sig) { - if (sig == SIGTERM) - keep_running = 0; + if (sig == SIGTERM) + keep_running = 0; } int -main (int argc, char *argv[]) +main(int argc, char *argv[]) { - glfs_t *fs = NULL; - int ret = 0; - glfs_fd_t *fd = NULL; - char *filename = NULL; - char *logfile = NULL; - char *host = NULL; - - if (argc != 5) { - return -1; - } - - host = argv[2]; - logfile = argv[3]; - filename = argv[4]; - - /* setup signal handler for exiting */ - signal (SIGTERM, stop_running); - - fs = glfs_new (argv[1]); - if (!fs) { - return -1; - } - - ret = glfs_set_volfile_server (fs, "tcp", host, 24007); - if (ret < 0) { - return -1; - } - - ret = glfs_set_logging (fs, logfile, 7); - if (ret < 0) { - return -1; - } - - ret = glfs_init (fs); - if (ret < 0) { - return -1; - } - - fd = glfs_creat (fs, filename, O_RDWR, 0644); - if (!fd) { - return -1; - } - - /* sleep until SIGTERM has been received */ - while (keep_running) { - sleep (1); - } - - ret = glfs_close (fd); - if (ret < 0) { - return -1; - } - - ret = glfs_fini (fs); - if (ret < 0) { - return -1; - } - - return 0; + glfs_t *fs = NULL; + int ret = 0; + glfs_fd_t *fd = NULL; + char *filename = NULL; + char *logfile = NULL; + char *host = NULL; + + if (argc != 5) { + return -1; + } + + host = argv[2]; + logfile = argv[3]; + filename = argv[4]; + + /* setup signal handler for exiting */ + signal(SIGTERM, stop_running); + + fs = glfs_new(argv[1]); + if (!fs) { + return -1; + } + + ret = glfs_set_volfile_server(fs, "tcp", host, 24007); + if (ret < 0) { + return -1; + } + + ret = glfs_set_logging(fs, logfile, 7); + if (ret < 0) { + return -1; + } + + ret = glfs_init(fs); + if (ret < 0) { + return -1; + } + + fd = glfs_creat(fs, filename, O_RDWR, 0644); + if (!fd) { + return -1; + } + + /* sleep until SIGTERM has been received */ + while (keep_running) { + sleep(1); + } + + ret = glfs_close(fd); + if (ret < 0) { + return -1; + } + + ret = glfs_fini(fs); + if (ret < 0) { + return -1; + } + + return 0; } |