Я не знаю, почему продолжаю встречаться [22] недопустимый аргумент в процессе.
исходный код, подобный этому
int MainLoop()
{
struct timeval timeout;
fd_set event;
int n, maxfd, newfd, rc, err_cnt = 0;
CSocket* pSocket;
int chktime, currtime;
char buff[MAX_PACKET_SIZE];
int MaxPosition, CurrPosition = 0;
WmBoard *pWmBoard;
MaxPosition = pCWmBoard->GetMaxPosition();
g_CAgent.Create(g_CsPort, g_CsAddr);
chktime = GetTime();
while(g_Running) {
timeout.tv_sec = 1; /* Second */
timeout.tv_usec = 0; /* micro Second */
pSocket = NULL;
maxfd = g_SockList.GetEventMask(&event);
n = select(maxfd, &event, (fd_set *)0,(fd_set *)0,
(struct timeval *) &timeout);
if(n > 0) {
pSocket = g_SockList.GetEventSock(&event);
if(pSocket != NULL)
{
newfd = pSocket->Accept();
if(newfd > 0)
{
err_cnt = 0;
pWmBoard = GetMinClientCH(MaxPosition);
if (pWmBoard != NULL)
{
rc = SendFD(pWmBoard->PipeFd, (void *)" ", 1, newfd);
if (rc <= 0)
{
char szTmp[128];
sprintf(szTmp,"FDSend Error=[%d]errno=[%d]",
newfd,errno);
g_CAgent.SendMessage("!S001", g_PgmName, szTmp);
g_Log.Write("[%s:%d][E] %s",
g_PgmName, g_Pid, szTmp);
/*
if(errno == EBADF) g_Running = FALSE;
*/
#if 0
if(pWmBoard -> ProcessID > 1)
kill(pWmBoard->ProcessID, SIGTERM);
#endif
pWmBoard->PipeFd = -1;
}
}
else
{
g_Log.Write("[%s:%d][E] client is full. value=%d",
g_PgmName, g_Pid, g_CurrCHPos);
g_Running = FALSE;
}
close(newfd);
}
else
{
g_Log.Write("[%s:%d][E] accept error. errno = [%d]",
g_PgmName, g_Pid, errno);
switch(errno)
{
case EMFILE : break; /* Too many open files */
case ENOENT : /* No such file or directory */
case EAGAIN : /* Try again */
case EINVAL : /* Invalid argument */
case ENOMSG : ; /* No message of desired type */
default :
ResetSocket();
}
}
}
else
g_Log.Write("[%s:%d] GetEventSock is NULL", g_PgmName, g_Pid);
}
else if (n == 0) {
currtime = GetTime();
if( currtime == 0 && chktime != currtime)
{ // ¸ÅÀÏ ÁöÁ¤ÇÑ ½Ã°£ (24½Ã)
g_Log.ReOpen();
g_MaxUser = 0;
ClearTotalTR();
}
chktime = currtime;
}
if (getppid() <= 1){
g_Running = FALSE;
}
if(WhatTime()) SendWmBoardInfo();
}
g_CAgent.Close();
return FALSE;
}
Мы называем процесс как WmCL и отправка WmCL данные в WmCH для соединения.
и я получил журнал, используя команду strace, результат такой же, как показано ниже.
select(19, [16 17 18], NULL, NULL, {1, 0}) = 1 (in [17], left {0, 914250})
accept(17, {sa_family=AF_INET, sin_port=htons(38610), sin_addr=inet_addr("114.122.207.70")}, [16]) = 20
sendmsg(9, {msg_name(0)=NULL, msg_iov(1)=[{" ", 1}], msg_controllen=24, {cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, {20}}, msg_flags=MSG_OOB|MSG_DONTROUTE|MSG_CTRUNC|0x10}, 0) = 1
close(20) = 0
getppid() = 17099
select(19, [16 17 18], NULL, NULL, {1, 0}) = 0 (Timeout)
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=344, ...}) = 0
getppid() = 17099
select(19, [16 17 18], NULL, NULL, {1, 0}) = 0 (Timeout)
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=344, ...}) = 0
getppid() = 17099
select(19, [16 17 18], NULL, NULL, {1, 0}) = ? ERESTARTNOHAND (To be restarted if no handler)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=18976, si_status=0, si_utime=1173, si_stime=797} ---
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG, NULL) = 18976
close(7) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=344, ...}) = 0
sendto(19, "m20192.168.103.22 1028360WmCL "..., 161, 0, {sa_family=AF_INET, sin_port=htons(8499), sin_addr=inet_addr("192.168.201.17")}, 16) = 161
write(5, "[10:28:36-000002][WmCL:17236][E]"..., 63) = 63
socketpair(PF_LOCAL, SOCK_STREAM, 0, [7, 20]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f287d4219f0) = 23210
close(20) = 0
как показано в журнале, «выбрать» результат равен «?» но я не знаю, почему получается «?» ....
Можете ли вы посоветовать мне решить эту проблему?