+}
+
+/**
+ * Send data as shared memory to a file descriptor.
+ *
+ * \param buf The buffer holding the data to be sent.
+ * \param size The size of \a buf.
+ * \param fd_ptr A pointer to the file descriptor.
+ *
+ * This function is used as the \a max_size handler in a \ref para_buffer
+ * structure. If used this way, it is called by \ref para_printf() whenever
+ * the buffer passed to para_printf() is about to exceed its maximal size.
+ *
+ * This function creates a shared memory area large enough to hold
+ * the content given by \a buf and \a size and sends the identifier
+ * of this area to the file descriptor given by \a fd_ptr.
+ *
+ * \return Zero if \a buf is \p NULL or \a size is zero. Negative on errors,
+ * and positive on success.
+ */
+int pass_buffer_as_shm(char *buf, size_t size, void *fd_ptr)
+{
+ int ret, shmid, fd = *(int *)fd_ptr;
+ void *shm;
+ struct callback_result *cr;
+
+ if (!buf || !size)
+ return 0;
+ ret = shm_new(size + sizeof(struct callback_result));
+ if (ret < 0)
+ return ret;
+ shmid = ret;
+ ret = shm_attach(shmid, ATTACH_RW, &shm);
+ if (ret < 0)
+ goto err;
+ cr = shm;
+ cr->result_size = size;
+ memcpy(shm + sizeof(*cr), buf, size);
+ ret = shm_detach(shm);
+ if (ret < 0)
+ goto err;
+ ret = send_bin_buffer(fd, (char *)&shmid, sizeof(int));
+ if (ret >= 0)
+ return ret;
+err:
+ if (shm_destroy(shmid) < 0)
+ PARA_ERROR_LOG("destroy result failed\n");
+ return ret;