Ghost processes in /proc with kernel 2.3.22

list.kernel@iahastie.clara.net
25 Oct 1999 09:33:16 GMT


Process numbers do not appear in the listing of proc, it is possible
to stat the contents of their directories. eg /proc/1234 does not
exist, but stat /proc/1234/stat does. cat /proc/1234/stat would
give an error.

I first came across the problem when skill was trying to get details
of a non-existant process. So I wrote a program to check for them.
This time I had been running Netscape. It had failed with a drop
down menu active and effectively locked X. Having killed Netscape
from a virtual terminal X crashed when I tried to switch back to it.
X then restarted on a different virtual terminal as if the original
was still open. So I ran my program and got the following output:

Ghost processes found :
2041 3625 4116 5095 6159 6439 7289 7666 7734
8043 8722 9306 11565 11950 13483 13663 13677 14248
4256 16851 18431 21753 22048 24059 24314 24343 24733
25572 26175 26262 28644 29055

This is the program I used:

#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>

int select(struct dirent *);

main(void) {
int list[33000], i;
struct dirent **procs;
struct stat statbuf;
int proc_count, found=0;
char buff[128];

memset(list, '\0', sizeof(list));

proc_count = scandir("/proc", &procs, select, NULL);

printf("Ghost processes found :\n");

for (i=0; i<proc_count; i++)
list[atoi(procs[i]->d_name)] = 1;

for (i=0; i<33000; i++) {
sprintf(buff, "/proc/%d/stat", i);

if ((stat(buff, &statbuf) != -1) && (list[i] != 1)) {
found = 1;
printf("%8d", i);
}
}

if (!found)
printf("None.");

printf("\n");

exit(0);
}

int select(struct dirent *ent) {
char *ptr=ent->d_name;

while (*ptr) {
if (*ptr < '0' || *ptr > '9')
return 0;

ptr++;
}

return 1;
}

Output from ver_linux:

Linux iahastie.clara.net 2.3.22 #1 Mon Oct 18 03:27:41 BST 1999 i586 unknown
Kernel modules 2.3.6
Gnu C 2.8.1
Binutils 2.9.1.0.24
Linux C Library 2.0.7
Dynamic linker ldd (GNU libc) 2.0.7
Linux C++ Library 2.7.2
Procps 2.0.2
Mount 2.9g
Net-tools 1.45
Console-tools 1999.03.02
Sh-utils 1.16
Modules Loaded mad16 ad1848 uart401 sound soundcore nfsd lockd
sunrpc dummy0 ipchains ip_defrag unix nls_iso8859-1
nls_cp437 vfat fat

Finally heres my .config. It's from kernel 2.3.23, but the 2.3.22 relevant
parts should be the same. All 'not set' removed to make it a bit shorter!

#
# Automatically generated make config: don't edit
#
CONFIG_X86=y
CONFIG_ISA=y

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y

#
# Processor type and features
#
CONFIG_M586TSC=y
CONFIG_X86_WP_WORKS_OK=y
CONFIG_X86_INVLPG=y
CONFIG_X86_BSWAP=y
CONFIG_X86_POPAD_OK=y
CONFIG_X86_TSC=y
CONFIG_NOHIGHMEM=y

#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODVERSIONS=y
CONFIG_KMOD=y

#
# General setup
#
CONFIG_NET=y
CONFIG_PCI=y
CONFIG_PCI_GOANY=y
CONFIG_PCI_BIOS=y
CONFIG_PCI_DIRECT=y

#
# Plug and Play configuration
#
CONFIG_PNP=m
CONFIG_ISAPNP=m

#
# Block devices
#
CONFIG_BLK_DEV_FD=m
CONFIG_BLK_DEV_IDE=y

#
# Please see Documentation/ide.txt for help/info on IDE drives
#
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_IDEDISK_MULTI_MODE=y
CONFIG_BLK_DEV_IDECD=m

#
# IDE chipset support/bugfixes
#
CONFIG_BLK_DEV_IDEPCI=y
CONFIG_BLK_DEV_IDEDMA_PCI=y
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_IDEDMA_PCI_EXPERIMENTAL=y
CONFIG_BLK_DEV_VIA82CXXX=y
CONFIG_BLK_DEV_IDEDMA=y
CONFIG_IDEDMA_AUTO=y

#
# Additional Block Devices
#
CONFIG_PARIDE_PARPORT=m

#
# Networking options
#
CONFIG_PACKET=m
CONFIG_PACKET_MMAP=y
CONFIG_NETLINK=y
CONFIG_NETFILTER=y
CONFIG_NETFILTER_DEBUG=y
CONFIG_FILTER=y
CONFIG_UNIX=m
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_SYN_COOKIES=y

#
# (it is safe to leave these untouched)
#
CONFIG_SKB_LARGE=y

#
# Network device support
#
CONFIG_NETDEVICES=y

#
# ARCnet devices
#
CONFIG_DUMMY=m

#
# Ethernet (10 or 100Mbit)
#
CONFIG_PPP=m
CONFIG_PPP_ASYNC=m
CONFIG_PPP_DEFLATE=m
CONFIG_PPP_BSDCOMP=m
CONFIG_SLIP=m
CONFIG_SLIP_COMPRESSED=y
CONFIG_SLIP_SMART=y

#
# Character devices
#
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_PRINTER=m

#
# Mice
#
CONFIG_NVRAM=m
CONFIG_RTC=y

#
# Ftape, the floppy tape device driver
#
CONFIG_DRM=y

#
# Filesystems
#
CONFIG_FAT_FS=m
CONFIG_MSDOS_FS=m
CONFIG_UMSDOS_FS=m
CONFIG_VFAT_FS=m
CONFIG_EFS_FS=m
CONFIG_ISO9660_FS=m
CONFIG_JOLIET=y
CONFIG_MINIX_FS=m
CONFIG_PROC_FS=y
CONFIG_EXT2_FS=y

#
# Network File Systems
#
CONFIG_NFS_FS=m
CONFIG_NFSD=m
CONFIG_NFSD_SUN=y
CONFIG_SUNRPC=m
CONFIG_LOCKD=m

#
# Partition Types
#
CONFIG_MSDOS_PARTITION=y
CONFIG_NLS=y

#
# Native Language Support
#
CONFIG_NLS_CODEPAGE_437=m
CONFIG_NLS_CODEPAGE_850=m
CONFIG_NLS_ISO8859_1=m

#
# Console drivers
#
CONFIG_VGA_CONSOLE=y
CONFIG_VIDEO_SELECT=y

#
# Sound
#
CONFIG_SOUND=m
CONFIG_SOUND_OSS=m
CONFIG_SOUND_MSS=m
CONFIG_SOUND_MPU401=m
CONFIG_SOUND_MAD16=m
CONFIG_SOUND_SOFTOSS=m
CONFIG_SOUND_SB=m
CONFIG_SOUND_YM3812=m

#
# Kernel hacking
#
CONFIG_MAGIC_SYSRQ=y

-- 
Ian.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/