+void fio_clients_terminate(void)
+{
+ struct flist_head *entry;
+ struct fio_client *client;
+
+ dprint(FD_NET, "client: terminate clients\n");
+
+ flist_for_each(entry, &client_list) {
+ client = flist_entry(entry, struct fio_client, list);
+
+ fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_QUIT, 0);
+ }
+}
+
+static void sig_int(int sig)
+{
+ dprint(FD_NET, "client: got sign %d\n", sig);
+ fio_clients_terminate();
+}
+
+static void client_signal_handler(void)
+{
+ struct sigaction act;
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = sig_int;
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGINT, &act, NULL);
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = sig_int;
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGTERM, &act, NULL);
+}
+
+static void probe_client(struct fio_client *client)
+{
+ dprint(FD_NET, "client: send probe\n");
+
+ fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_PROBE, 0);
+ handle_client(client, 1);
+}
+
+static int send_client_cmd_line(struct fio_client *client)
+{
+ struct cmd_line_pdu *pdu;
+ int i, ret;
+
+ dprint(FD_NET, "client: send cmdline %d\n", client->argc);
+
+ pdu = malloc(sizeof(*pdu));
+ for (i = 0; i < client->argc; i++)
+ strcpy((char *) pdu->argv[i], client->argv[i]);
+
+ pdu->argc = cpu_to_le16(client->argc);
+ ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOBLINE, pdu, sizeof(*pdu));
+ free(pdu);
+ return ret;
+}
+