Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-07-2006, 03:44 AM   #1
LQ Newbie
Registered: Aug 2006
Posts: 17

Rep: Reputation: 0
Unhappy problem with g_io_add_watch()

hi ppl,

i think i have left out something obvious, but dont know wat that obvious thing is..

my callback never get called when i use g_io_add_watch()

the code is....
static gboolean hald_udev_data(GIOChannel *source, GIOCondition condition, gpointer user_data)
int fd;
int retval;
struct msghdr smsg;
struct cmsghdr *cmsg;
struct iovec iov;
struct ucred *cred;
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
char buf[4096];
size_t bufpos = 0;
const char *action = NULL;
memset(buf, 0x00, sizeof (buf));

fd = g_io_channel_unix_get_fd (source);

iov.iov_base = &buf;
iov.iov_len = sizeof (buf);

memset(&smsg, 0x00, sizeof (struct msghdr));
smsg.msg_iov = &iov;
smsg.msg_iovlen = 1;
smsg.msg_control = cred_msg;
smsg.msg_controllen = sizeof (cred_msg);
retval = recvmsg (fd, &smsg, 0);
printf("\nError recieving mesage from udev");
return TRUE;


void osspec_init()
int udev_socket,on=1;
struct sockaddr_un saddr;
GIOChannel *udev_channel;
socklen_t addrlen;

addrlen=offsetof(struct sockaddr_un,sun_path) + strlen(saddr.sun_path + 1);

printf("Error creating socket");
printf("\nSocket created..");
bind(udev_socket,(struct sockaddr *) &saddr,addrlen);

setsockopt(udev_socket, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
udev_channel = g_io_channel_unix_new (udev_socket);
g_io_add_watch (udev_channel, G_IO_IN, hald_udev_data, NULL);
g_io_channel_unref (udev_channel);


thank u in advance.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:39 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration