09-27-2008
a for loop that doesn't make sense
I've been referring bash info for processes and came across a structure for a process which is defined like
typedef struct process
{
struct process *next;
char ** argv
.
.
.
}process;
What I don't understand is that in the program there's a for loop which goes like this
job *j;//pointer to a structure that holds data about the jobs running
process *p;//pointer to a structure that holds process information
for(p=j->first_process;p;p=p->next) {...}
I don't understand how the p highlighted in red can be used as a condition in a for loop. What purpose does it serve? How does the for loop evaluate p as a terminating condition for the loop?
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hi
I wrote the following makefile, I have just one problem, when i type make clean I get the message make 'clean' is up to date and any obj file is removed from my folder, what's wrong?
Thank you
CC = cc
all: es.o elaboration.o
$(CC) -o es es.o elaboration.o
elaboration.o:... (0 Replies)
Discussion started by: Puntino
0 Replies
2. High Performance Computing
08-18-2008 11:00 AM
Cluster computing has played a pivotal role in the way research is conducted in educational environments. Because the amount of available money and hardware varies between university researchers, often it's necessary to find a clustering solution that can work well on a small... (0 Replies)
Discussion started by: Linux Bot
0 Replies
3. UNIX for Dummies Questions & Answers
I'm running the following rsync command to sync a directory between the 2 servers:
rsync -az --delete --stats /some_dir/ server_name:/some_dir
I'm getting the following output:
Number of files: 655174
Number of files transferred: 14221
Total file size: 1138531979331 bytes
Total... (0 Replies)
Discussion started by: GKnight
0 Replies
4. Shell Programming and Scripting
It's been a while since I had to write a Makefile, but I've managed to clobber this together:
SRC=module1.c module2.c
OBJS=$(SRC:%.c=%.o)
HDR=include1.h include2.h
CC=gcc
CFLAGS=-Wall -ggdb -D_XOPEN_SOURCE -I. -ansi
all: program
program: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
... (3 Replies)
Discussion started by: pludi
3 Replies
5. UNIX for Advanced & Expert Users
Can someone explain the correlation between how sar names the disk drives and how the rest of the OS names the disk drives?
sar lists my disk drives as sd0, sd1, sd2, etc.....
while format lists my disk drives as c1t0d0, c1t1d0, c1t2d0,etc...
And also why sar shows 8 disks but format... (2 Replies)
Discussion started by: s ladd
2 Replies
6. Cybersecurity
I stumbled upon this thread and one aspect of it got me thinking. As i am building a small Linux network right now for a friend i would like to hear your opinion on this.
I'd like to respectfully disagree. I think the Linux habit of disabling root login per default is wrong (not entirely... (6 Replies)
Discussion started by: bakunin
6 Replies
7. Shell Programming and Scripting
I'm trying to send the file list as parameter to another job and execute it.
But the loop doesn't work, the inner job is running only once and not twice as expected
for filelist in $(ls -rt *.txt | tail -2)
do
echo $filelist
export filelist
cmd="$Program -config $configfile -autoexec... (11 Replies)
Discussion started by: asandy1234
11 Replies
8. Red Hat
We have several dozen Redhat 5, 6 and 7 servers that are running Oracle databases. On some databases we are using automatic memory management, which uses shared memory. On other databases we are use manual memory management, which does not use shared memory.
When I see that a server is swapping... (2 Replies)
Discussion started by: gandolf989
2 Replies
LEARN ABOUT OPENSOLARIS
kvm_getproc
kvm_nextproc(3KVM) Kernel VM Library Functions kvm_nextproc(3KVM)
NAME
kvm_nextproc, kvm_getproc, kvm_setproc - read system process structures
SYNOPSIS
cc [ flag... ] file... -lkvm [ library...]
#include <kvm.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/proc.h>
struct proc *kvm_nextproc(kvm_t *kd);
int kvm_setproc(kvm_t *kd);
struct proc *kvm_getproc(kvm_t *kd, pid_t pid);
DESCRIPTION
The kvm_nextproc() function reads sequentially all of the system process structures from the kernel identified by kd (see kvm_open(3KVM)).
Each call to kvm_nextproc() returns a pointer to the static memory area that contains a copy of the next valid process table entry. There
is no guarantee that the data will remain valid across calls to kvm_nextproc(), kvm_setproc(), or kvm_getproc(). If the process structure
must be saved, it should be copied to non-volatile storage.
For performance reasons, many implementations will cache a set of system process structures. Since the system state is liable to change
between calls to kvm_nextproc(), and since the cache may contain obsolete information, there is no guarantee that every process structure
returned refers to an active process, nor is it certain that all processes will be reported.
The kvm_setproc() function rewinds the process list, enabling kvm_nextproc() to rescan from the beginning of the system process table. This
function will always flush the process structure cache, allowing an application to re-scan the process table of a running system.
The kvm_getproc() function locates the proc structure of the process specified by pid and returns a pointer to it. Although this function
does not interact with the process table pointer manipulated by kvm_nextproc(), the restrictions regarding the validity of the data still
apply.
RETURN VALUES
On success, kvm_nextproc() returns a pointer to a copy of the next valid process table entry. On failure, it returns NULL.
On success, kvm_getproc() returns a pointer to the proc structure of the process specified by pid. On failure, it returns NULL.
The kvm_setproc() function returns 0 on success and -1 on failure.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Stable |
+-----------------------------+-----------------------------+
|MT-Level |Unsafe |
+-----------------------------+-----------------------------+
SEE ALSO
kvm_getu(3KVM), kvm_open(3KVM), kvm_kread(3KVM), attributes(5)
SunOS 5.11 2 May 2002 kvm_nextproc(3KVM)