[zeromq-dev] Pass arguments via zthread_fork

Bachmair Florian - flexSolution GmbH florian.bachmair at flexsolution.eu
Tue Apr 14 14:01:22 CEST 2015


Hi!

I have a *char[] with parameter which I wanna hand over to my subscriber 
thread.
I tried it with my own method which needs an void-pointer as well. There 
I can read the parameters sucesffuly, but not If I start a Thread via 
zthread_fork

Here's some sample code to Illustrate my problem

static void fillArguments(){
         char* args[2];
         args[1]="a";
         args[2]="b";
     anyMethod(args);
     zthread_fork(context, subscriber_thread, args);
}
//Here it works fine
static void anyMethod(void *args) {
     puts("anyMethod begin");
     char **strargs = (char **) args;
     puts(strargs[0]);
     puts(strargs[1]);
     fflush(stdout);
     puts("anyMethod end");
}
//Here I can't read the parameters, Just get weired values
static void subscriber_thread(void *args, zctx_t *ctx, void *pipe) {
     puts("Subscribe thread");
     fflush(stdout);

     char **strargs = (char **) args;

     int i;
     puts(strargs[0]);
     puts(strargs[1]);
     fflush(stdout);
}

Thx
Florian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150414/355524ed/attachment.htm>


More information about the zeromq-dev mailing list