LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-07-2006, 03:44 AM   #1
arvind.ayyangar
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);
if(retval==-1){
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;
memset(&saddr,0x00,sizeof(saddr));

saddr.sun_family=AF_LOCAL;
strcpy(&saddr.sun_path[1],"/org/freedesktop/hal/udev_event");
addrlen=offsetof(struct sockaddr_un,sun_path) + strlen(saddr.sun_path + 1);

udev_socket=socket(AF_LOCAL,SOCK_DGRAM,0);
if(udev_socket==-1){
printf("Error creating socket");
exit(0);
}
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.
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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