473,395 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Process ID problem

Hi, below is code for a child process, i am trying to give it a group
ID which is +10 on the group ID of the parent process (writing a
simple shell here)
Somehow both print statements show same group ID as if setpgid has no
effect...

if((pid_child2=fork())==0)
{
printf("***hello from c2\n");

printf(" ***c2 gpid used to be %d\n", getpgid(0));
int pgpid = getpgid(0);
setpgid(0,pgpid+10);
printf(" ***c2 gpid was set to %d\n", getpgid(0));
..
..
..
}
SCREEN OUTPUT --->

***hello from c2
***c2 gpid used to be 15946
***c2 gpid was set to 15946
-------------------------

UPDATE:
both setpgid calls are returning -1 and errno EPERM.
Could this be due to the adding of 10 to pgpid ? is that
allowed. The reason i am picking this pgid (x+1) is because i have
two children processos and want them both to have same group ID as
each other, but yet different from there parent.

Any ideas ? Thanks

Feb 6 '07 #1
2 1645
In article <11*********************@a75g2000cwd.googlegroups. com>,
sdac <am*****@gmail.comwrote:
>Hi, below is code for a child process, i am trying to give it a group
ID which is +10 on the group ID of the parent process (writing a
simple shell here)
Processes and group ids are not part of the C language, and are
artifacts of the operating system you are using. For assistance
with your difficulty, you should consult a group that specializes
in your operating system. Perhaps comp.unix.programming .
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton
Feb 6 '07 #2
sdac wrote:
[...]
printf(" ***c2 gpid used to be %d\n", getpgid(0));
int pgpid = getpgid(0);
setpgid(0,pgpid+10);
printf(" ***c2 gpid was set to %d\n", getpgid(0));
[...]
SCREEN OUTPUT --->

***hello from c2
***c2 gpid used to be 15946
***c2 gpid was set to 15946
-------------------------

UPDATE:
both setpgid calls are returning -1 and errno EPERM.
While most of the above is OT for clc, the fact that errno is
being set to EPERM is a major hint. Check the man pages on
setpgid() and see what could cause that error. If that doesn't
help, the you need to go to a group where this would be topical,
perhaps comp.unix.programming.

[Hint: many if the "set" calls like this do not allow arbitrary
values to be set. Consider, for example, "setuid(getuid()+1)".]

[...]

--
+-------------------------+--------------------+-----------------------+
| Kenneth J. Brody | www.hvcomputer.com | #include |
| kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h|
+-------------------------+--------------------+-----------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>
Feb 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sorin Dolha [MCSD .NET] | last post by:
I would like to start a process from C# code as another user. The C# code is executed as the ASPNET user because it relies in a Web Page class, and I would like that the process will run as another...
2
by: Praveen K | last post by:
I have a problem in communicating between the C# and the Excel Interop objects. The problem is something as described below. I use Microsoft Office-XP PIA dll’s as these dll’s were been...
12
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my...
80
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
22
by: Zen | last post by:
Hi, My production machine has 2G of memory, when aspnet_wp.exe goes up to about ~1.2G of memory usage, I start get out-of-memory exception. Other processes don't use as much memory and I added...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.