move-fd.h (2067B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#ifndef GUACD_MOVE_FD_H 21#define GUACD_MOVE_FD_H 22 23#include "config.h" 24 25/** 26 * Sends the given file descriptor along the given socket, allowing the 27 * receiving process to use that file descriptor normally. Returns non-zero on 28 * success, zero on error, just as a normal call to sendmsg() would. If an 29 * error does occur, errno will be set appropriately. 30 * 31 * @param sock 32 * The file descriptor of an open UNIX domain socket along which the file 33 * descriptor specified by fd should be sent. 34 * 35 * @param fd 36 * The file descriptor to send along the given UNIX domain socket. 37 * 38 * @return 39 * Non-zero if the send operation succeeded, zero on error. 40 */ 41int guacd_send_fd(int sock, int fd); 42 43/** 44 * Waits for a file descriptor on the given socket, returning the received file 45 * descriptor. The file descriptor must have been sent via guacd_send_fd. If an 46 * error occurs, -1 is returned, and errno will be set appropriately. 47 * 48 * @param sock 49 * The file descriptor of an open UNIX domain socket along which the file 50 * descriptor will be sent (by guacd_send_fd()). 51 * 52 * @return 53 * The received file descriptor, or -1 if an error occurs preventing 54 * receipt of the file descriptor. 55 */ 56int guacd_recv_fd(int sock); 57 58#endif 59