+static
+int send_fd_to_worker(struct run_as_worker *worker, enum run_as_cmd cmd, int fd)
+{
+ int ret = 0;
+
+ switch (cmd) {
+ case RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET:
+ break;
+ default:
+ return 0;
+ }
+
+ ret = do_send_fd(worker->sockpair[0], fd);
+ if (ret < 0) {
+ PERROR("do_send_fd");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+static
+int send_fd_to_master(struct run_as_worker *worker, enum run_as_cmd cmd, int fd)
+{
+ int ret = 0, ret_close = 0;
+
+ switch (cmd) {
+ case RUN_AS_OPEN:
+ break;
+ default:
+ return 0;
+ }
+
+ ret = do_send_fd(worker->sockpair[1], fd);
+ if (ret < 0) {
+ PERROR("do_send_fd error");
+ ret = -1;
+ }
+
+ ret_close = close(fd);
+ if (ret_close < 0) {
+ PERROR("close");
+ }
+
+ return ret;
+}
+
+static
+int recv_fd_from_worker(struct run_as_worker *worker, enum run_as_cmd cmd, int *fd)
+{
+ int ret = 0;
+
+ switch (cmd) {
+ case RUN_AS_OPEN:
+ break;
+ default:
+ return 0;
+ }
+
+ ret = do_recv_fd(worker->sockpair[0], fd);
+ if (ret < 0) {
+ PERROR("do_recv_fd error");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+static
+int recv_fd_from_master(struct run_as_worker *worker, enum run_as_cmd cmd, int *fd)
+{
+ int ret = 0;
+
+ switch (cmd) {
+ case RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET:
+ break;
+ default:
+ return 0;
+ }
+
+ ret = do_recv_fd(worker->sockpair[1], fd);
+ if (ret < 0) {
+ PERROR("do_recv_fd error");
+ ret = -1;
+ }
+
+ return ret;
+}
+
+static
+int cleanup_received_fd(enum run_as_cmd cmd, int fd)
+{
+ int ret = 0;
+
+ switch (cmd) {
+ case RUN_AS_EXTRACT_ELF_SYMBOL_OFFSET:
+ break;
+ default:
+ return 0;
+ }
+
+ ret = close(fd);
+ if (ret < 0) {
+ PERROR("close error");
+ ret = -1;
+ }
+
+ return ret;
+}