FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix returned file descriptors getting closed immediately by luleyleo · Pull Request #121 · python-sdbus/python-sdbus · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions src/sdbus/sd_bus_internals_message.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <fcntl.h>
#include "sd_bus_internals.h"

void _SdBusMessage_set_messsage(SdBusMessageObject* self, sd_bus_message* new_message) {
Expand Down Expand Up @@ -800,6 +801,10 @@ static PyObject* _iter_basic(sd_bus_message* message, char basic_type) {
case 'h': {
int new_fd = 0;
CALL_SD_BUS_AND_CHECK(sd_bus_message_read_basic(message, basic_type, &new_fd));

// The fd is owned by the message and would be closed after the end of the message's lifetime
new_fd = CALL_SD_BUS_AND_CHECK(fcntl(new_fd, F_DUPFD_CLOEXEC, 3));

return PyLong_FromLong((long)new_fd);
break;
}
Expand Down

Back | FazBrowse Home | New Git URL