I defeated the segfaults! Now the monster in the next level is named smart_str. I have a smart_str to buffer the SAPI output.
On the first request no output comes out. Second request gives the correct output. All following request return some bytes of garbarge. The relevant code parts: typedef struct _gearman_worker_request_struct { smart_str result; } gearman_worker_request_struct; static void gearman_worker_globals_ctor(gearman_worker_request_struct *request TSRMLS_DC) { memset( &request->result, 0, sizeof(smart_str) ); } static void gearman_worker_globals_dtor(gearman_worker_request_struct *request TSRMLS_DC) { smart_str_free(&GWR(result)); } static int php_embed_ub_write(const char *str, uint str_length TSRMLS_DC) { smart_str_appendl(&GWR(result), str, (int) str_length); return str_length; } char *php_gearman_worker_get_result(TSRMLS_D) { char *result; smart_str_0(&GWR(result)); result = strndup( GWR(result).c, GWR(result).len ); return result; } and in the sapi startup: ts_allocate_id(&gearman_worker_id, sizeof(gearman_worker_request_struct), (ts_allocate_ctor) gearman_worker_globals_ctor, (ts_allocate_dtor) gearman_worker_globals_dtor); Thanks for your patience!!! Thomas Koch, http://www.koch.ro -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php