这是我的服务器程序
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/un.h>
#include<sys/types.h>
#include<unistd.h>
int main ()
{
int server_sockfd,client_sockfd;
int server_len,client_len;
struct sockaddr_un server_address;
struct sockaddr_un client_address;
unlink("server_socket");
server_sockfd=socket(AF_UNIX,SOCK_STREAM,0);//created socket
server_address.sun_family=AF_UNIX;
strcpy(server_address.sun_path,"server_socket");
server_len=sizeof(server_address);
bind(server_sockfd,(struct sockaddr *)&server_address,server_len);//binded it
listen(server_sockfd,5);
while (1)
{
char ch;
printf("server waiting\n");
client_len=sizeof(client_address);
client_sockfd=accept(server_sockfd,(struct sockaddr *)&client_address,&client_len);
read(client_sockfd,&ch,1);
ch++;
write(client_sockfd,&ch,1);
close(client_sockfd);
}
}
我按如下方式编制了上述程序
cc server.c -o server.o
当我运行ps -el | grep server.o
时,我得到以下输出
0 S 1000 4450 2228 0 80 0 - 965 skb_re pts/0 00:00:00 server.o
我想知道上面输出中S
的含义是什么?
答案 0 :(得分:2)
这意味着“可以中断睡眠”。这可能意味着它正在阻塞系统调用中等待。在您的情况下,系统调用很可能是accept
或read
。
ps(1)
以下是不同的值 s,stat和state输出说明符 (标题“STAT”或“S”)将显示为 描述过程的状态。
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.
答案 1 :(得分:2)
S
标记正在睡眠时间少于20的进程 秒。强>D
在磁盘中标记进程(或其他短期,不可中断) 等待。I
标记一个闲置的进程(睡眠时间超过20左右) 秒)。L
标记正在等待获取锁定的进程。R
标记可运行的进程。T
标记已停止的流程。W
标记空闲中断线程。Z
标记死亡过程(“僵尸”)。