c - Can I send char* with sigqueue to another process -
here part of code in client program
union sigval toserver; char *test = "dummy"; serverpid = atol(buf2); toserver.sival_ptr = (void *)test; // register server if (sigqueue(serverpid, sigusr1, toserver) == -1) { // register fprintf(stderr," server isn't ready!\n"); return 1; } here handler in server program
static void register_handler(int signo, siginfo_t* info, void *context) { registeredprogramid = info->si_pid; if(info->si_value.sival_ptr != null) fprintf(stderr," sent value = %s \n" ,(char *)info->si_value.sival_ptr); } there no error can't sent. prints weird.
no cannot.
you can send char*, receiving process doesn't have access memory of sending process , memory may mapped differently. when access memory address pointed received pointer result undefined (i.e. platform specific , not repeatable). result either kind of memory protection error or read memory contains random value.
Comments
Post a Comment