Sir, As u told me i had used strace -ppid
and here is the output what I am getting........
it is showing me two pids for a same process........and when I used to strace to them then its showing me following outputs .........
outputs::::::::
[root@localhost New Folder]#strace -p3153
Process 3153 attached - interrupt to quit
write(5, "\0i, I am fine101010\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 100
<unfinished ...>
Process 3153 detached
[root@localhost New Folder]# strace -p3152
Process 3152 attached - interrupt to quit
wait4(-1,
Why is it sitting in wait4()? looks like it thinks the child process should be dead and it's trying to reap it, so it has fallen out of the select loop.
The two pids are one for the main process and another for the child process, which is what we were trying to achieve.
I had put wait in parent ....so that parent will not terminate untill child will not free its resources........If I will not use wait in parent, the parent will terminate and child will be running.........
Yes that's fine, but it's not going to be waiting for input in select if it's blocking in wait4.
your main process should be
pid_child=fork();
if (!pid_child)
{
exit(run_child());
}
while (running)
{
set up fd_sets
select
do reads,writes and other stuff
}
kill(pid_child,SIGINT);
waitpid(pid_child...)
you had send me this code.....but I didnt able to understand why you had used p+=i; where p is a char string ......
moreover I am getting more difficulties with code...i.e through pipe read end I am not able to read the data.....
when i check for strace -ppid its showing continously polling (for parent) with select
and child witing for msgrcv()......
Sir,
now facing problem while using socket comm. and select........my message queue and pipe part is working ....no problem at that side....
my application is continously reading through pipe but when socket comes into picture (my socket is server side (tcp/ip))....it reads only once through socket .....and I had to start client again.
this means that polling is again started with new socket connection......not as per read call.......
so how to implement....tell some steps to follow??????
please guide
I am only having one client attached to the server.....(acc to my system).
first of all I starts my server.....and from another system I starts client ....now connection got established after that client tries to send sone data...my server recieves it correctly(I am using client fd to collect what server is sending)....after that when client tries to send some more packets or data then it fails ......means its polls only once.....after that it doesnt read any packet......
please tell me which file drscriptor should i use to read and send data......
int fd_server=socket(AF_INET,SOCK_STREAM,0);
bind(fd_server,...
listen(fd_server,..
when socket fd_server is readable do
fd_client=accept(fd_server,...)
then use the fd_client to send() and recv() on, and finally close() when you are finished with that client.
While you have one client, another client can come in and try and connect, so hence you need to work out how to accept and manage multiple client connections each with their own file descriptor.
int msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg);
The msgrcv() function will fail if:
[EINVAL] The msqid argument is not a valid message queue iden-
tifier.
The message queue was removed while msgrcv() was wait-
ing for a message of the requested type to become
available on it.
The msgsz argument is less than 0.