Re: Attach my own pid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 21 Mar 2016 16:01:41 +0530, Nitin Varyani said:

> I am running a master user-level process at Computer 1 which sends a
> process context like code, data, registers, PC, etc as well as *"pid"* to
> slave processes running at other computers. The responsibility of the slave
> process is to fork a new process on order of master process and attach *"pid"
> *given by the master to the new process it has forked. Any system call on
> slave nodes will have an initial check of " Whether the process belongs to
> local node or to the master node?". That is, if kernel at Computer 2 pid of
> the process is 1500

None of that requires actually controlling the PID of the child.

Consider this code:


int child_pid[5], j;
pid_t child;

for (j=0;j<5;j++) {
	child =  fork();
	if (child == 0)
		go_init_worker_process();
	else
		child_pid[j] = child;
}

Now you have 5 children, and know what process IDs they are, without
having to do any kernel hacking at all.  This has been a long-understood
idiom in the Unix/Linux world - I remember first seeing it on SunOS 3.2 back
in 1985 or so...

Attachment: pgp3beUKeXjcD.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux