trouble of libpcap

I use libpcap to catch the data from network,there are 6 port on my target,wm0-wm5,I use pcap_loop(pd, -1, capture_packet1, pcap_userdata) to bind the wm0-wm5, capture_packet1 to wm0, capture_packet2 to wm1 etc,but I have some problem below:
1)sometimes I can’t get data when the programme runs,but at the same time if I run another process or I kill the process and let it run again,I will get the data.
2)the physical connection is wm0,it means I put the netline on wm0,but the programme shows that I get data from other port,like wm2,sometimes shows get data from 2 port,like wm2 and wm5
Could you help me?

This sounds like a libpcap problem. I know nothing about it, but I think your best bet would be to post the code in case someone else here does.