Linux RedHat kernel: what kernel is best?
- andrushok
- Novice


- Joined: May 21, 2004
- Posts: 24
- Status: Offline
I installed RedHat 9 on some server and upgrade kernel up to newest version: kernel-smp-2.4.20-31.9 Some my application stopped working. I debugged it and found the following probem:
after fork() I try to lock file using lockf(). On child branch I lunch the new application using execl(). Usualy (on any Unix and RedHat 7.1) the child process keeps the lock. However, in this case the child process losses the lock and my application work wrong.
I downgraded kernel down to kernel-smp-2.4.20-28.9 and the appication started working fine.
I checked the bug list on http://www.redhat.com and found nothing about that. Does sombody hear about this problem?
after fork() I try to lock file using lockf(). On child branch I lunch the new application using execl(). Usualy (on any Unix and RedHat 7.1) the child process keeps the lock. However, in this case the child process losses the lock and my application work wrong.
I downgraded kernel down to kernel-smp-2.4.20-28.9 and the appication started working fine.
I checked the bug list on http://www.redhat.com and found nothing about that. Does sombody hear about this problem?
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
May 21st, 2004, 11:34 am
- b_heyer
- Web Master


- Joined: Jun 15, 2003
- Posts: 4583
- Loc: Maryland
- Status: Offline
- andrushok
- Novice


- Joined: May 21, 2004
- Posts: 24
- Status: Offline
What is the package did I miss? I downloades RPMs from ftp.redhat.com and installed it using rpm command. I did not compile kernels.
I have the tested code
The normal output is:
However , if I applied the new kernel I have the following:
What do I need to add to the new kernel to restore normal work according to POSIX standard?
I have the tested code
Code: [ Select ]
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
int main( int args, char* argv[])
{
pid_t spid = getpid();
if( args == 1 )
printf( "\n\n[%d]: Parent process started\n", spid);
else if( args == 3 )
{
printf( "[%d]: Child process started\n", spid);
sleep( 15);
printf( "[%d]: Child process done!!!\n", spid);
return 0;
}
pid_t pid = fork();
int status;
switch( pid )
{
case -1:
printf( "[%d] fork failed.\n", spid);
exit( 0);
case 0:
{
pid_t pid = getpid();
printf( "[%d]->[%d] Child forked\n", spid, pid);
int hOutFile = creat( "test.out", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
| S_IWOTH);
int rl = lockf( hOutFile, F_LOCK, 100);
if( !rl )
printf( "[%d]->[%d] File 'test.out' locked\n", spid, pid);
else
{
printf( "[%d]->[%d] File 'test.out' did not lock, process failed\n", spid
, pid);
exit( 0);
}
if( execl( argv[0], argv[0], "-child", "-pending", NULL) == -1 )
{
printf( "[%d]->[%d] Execute '%s' failed\n", spid, pid, argv[0]);
exit( 0);
}
}
default:
printf( "[%d] Parent forked\n", spid);
break;
}
printf( "[%d] Sleep 10 seconds.\n", spid);
sleep( 10);
printf( "[%d] Check lock (should be locked!).\n", spid);
int hOutFile = open( "test.out", O_RDONLY);
int rl = lockf( hOutFile, F_TEST, 100);
printf( "[%d] Lock of file '%d' is %d.\n", spid, hOutFile, rl);
printf( "[%d] Sleep 10 seconds.\n", spid);
sleep( 10);
printf( "[%d] Wake up!, check lock (should be NOT locked!).\n", spid);
rl = lockf( hOutFile, F_TEST, 100);
printf( "[%d] Lock of file '%d' is %d.\n", spid, hOutFile, rl);
printf( "[%d] Parent Done!!!\n", spid);
return 0;
}
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
int main( int args, char* argv[])
{
pid_t spid = getpid();
if( args == 1 )
printf( "\n\n[%d]: Parent process started\n", spid);
else if( args == 3 )
{
printf( "[%d]: Child process started\n", spid);
sleep( 15);
printf( "[%d]: Child process done!!!\n", spid);
return 0;
}
pid_t pid = fork();
int status;
switch( pid )
{
case -1:
printf( "[%d] fork failed.\n", spid);
exit( 0);
case 0:
{
pid_t pid = getpid();
printf( "[%d]->[%d] Child forked\n", spid, pid);
int hOutFile = creat( "test.out", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
| S_IWOTH);
int rl = lockf( hOutFile, F_LOCK, 100);
if( !rl )
printf( "[%d]->[%d] File 'test.out' locked\n", spid, pid);
else
{
printf( "[%d]->[%d] File 'test.out' did not lock, process failed\n", spid
, pid);
exit( 0);
}
if( execl( argv[0], argv[0], "-child", "-pending", NULL) == -1 )
{
printf( "[%d]->[%d] Execute '%s' failed\n", spid, pid, argv[0]);
exit( 0);
}
}
default:
printf( "[%d] Parent forked\n", spid);
break;
}
printf( "[%d] Sleep 10 seconds.\n", spid);
sleep( 10);
printf( "[%d] Check lock (should be locked!).\n", spid);
int hOutFile = open( "test.out", O_RDONLY);
int rl = lockf( hOutFile, F_TEST, 100);
printf( "[%d] Lock of file '%d' is %d.\n", spid, hOutFile, rl);
printf( "[%d] Sleep 10 seconds.\n", spid);
sleep( 10);
printf( "[%d] Wake up!, check lock (should be NOT locked!).\n", spid);
rl = lockf( hOutFile, F_TEST, 100);
printf( "[%d] Lock of file '%d' is %d.\n", spid, hOutFile, rl);
printf( "[%d] Parent Done!!!\n", spid);
return 0;
}
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/wait.h>
- int main( int args, char* argv[])
- {
- pid_t spid = getpid();
- if( args == 1 )
- printf( "\n\n[%d]: Parent process started\n", spid);
- else if( args == 3 )
- {
- printf( "[%d]: Child process started\n", spid);
- sleep( 15);
- printf( "[%d]: Child process done!!!\n", spid);
- return 0;
- }
- pid_t pid = fork();
- int status;
- switch( pid )
- {
- case -1:
- printf( "[%d] fork failed.\n", spid);
- exit( 0);
- case 0:
- {
- pid_t pid = getpid();
- printf( "[%d]->[%d] Child forked\n", spid, pid);
- int hOutFile = creat( "test.out", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
- | S_IWOTH);
- int rl = lockf( hOutFile, F_LOCK, 100);
- if( !rl )
- printf( "[%d]->[%d] File 'test.out' locked\n", spid, pid);
- else
- {
- printf( "[%d]->[%d] File 'test.out' did not lock, process failed\n", spid
- , pid);
- exit( 0);
- }
- if( execl( argv[0], argv[0], "-child", "-pending", NULL) == -1 )
- {
- printf( "[%d]->[%d] Execute '%s' failed\n", spid, pid, argv[0]);
- exit( 0);
- }
- }
- default:
- printf( "[%d] Parent forked\n", spid);
- break;
- }
- printf( "[%d] Sleep 10 seconds.\n", spid);
- sleep( 10);
- printf( "[%d] Check lock (should be locked!).\n", spid);
- int hOutFile = open( "test.out", O_RDONLY);
- int rl = lockf( hOutFile, F_TEST, 100);
- printf( "[%d] Lock of file '%d' is %d.\n", spid, hOutFile, rl);
- printf( "[%d] Sleep 10 seconds.\n", spid);
- sleep( 10);
- printf( "[%d] Wake up!, check lock (should be NOT locked!).\n", spid);
- rl = lockf( hOutFile, F_TEST, 100);
- printf( "[%d] Lock of file '%d' is %d.\n", spid, hOutFile, rl);
- printf( "[%d] Parent Done!!!\n", spid);
- return 0;
- }
The normal output is:
Code: [ Select ]
[10314]: Parent process started
[10314]->[10315] Child forked
[10314]->[10315] File 'test.out' locked
[10315]: Child process started
[10314] Parent forked
[10314] Sleep 10 seconds.
[10314] Check lock (should be locked!).
[10314] Lock of file '3' is -1. (!!!!) this is fine!
[10314] Sleep 10 seconds.
[10315]: Child process done!!!
[10314] Wake up!, check lock (should be NOT locked!).
[10314] Lock of file '3' is 0.
[10314] Parent Done!!!
[10314]->[10315] Child forked
[10314]->[10315] File 'test.out' locked
[10315]: Child process started
[10314] Parent forked
[10314] Sleep 10 seconds.
[10314] Check lock (should be locked!).
[10314] Lock of file '3' is -1. (!!!!) this is fine!
[10314] Sleep 10 seconds.
[10315]: Child process done!!!
[10314] Wake up!, check lock (should be NOT locked!).
[10314] Lock of file '3' is 0.
[10314] Parent Done!!!
- [10314]: Parent process started
- [10314]->[10315] Child forked
- [10314]->[10315] File 'test.out' locked
- [10315]: Child process started
- [10314] Parent forked
- [10314] Sleep 10 seconds.
- [10314] Check lock (should be locked!).
- [10314] Lock of file '3' is -1. (!!!!) this is fine!
- [10314] Sleep 10 seconds.
- [10315]: Child process done!!!
- [10314] Wake up!, check lock (should be NOT locked!).
- [10314] Lock of file '3' is 0.
- [10314] Parent Done!!!
However , if I applied the new kernel I have the following:
Code: [ Select ]
[10314]: Parent process started
[10314]->[10315] Child forked
[10314]->[10315] File 'test.out' locked
[10315]: Child process started
[10314] Parent forked
[10314] Sleep 10 seconds.
[10314] Check lock (should be locked!).
[10314] Lock of file '3' is 0. (!!!!) ERROR!
[10314] Sleep 10 seconds.
[10315]: Child process done!!!
[10314] Wake up!, check lock (should be NOT locked!).
[10314] Lock of file '3' is 0.
[10314] Parent Done!!!
[10314]->[10315] Child forked
[10314]->[10315] File 'test.out' locked
[10315]: Child process started
[10314] Parent forked
[10314] Sleep 10 seconds.
[10314] Check lock (should be locked!).
[10314] Lock of file '3' is 0. (!!!!) ERROR!
[10314] Sleep 10 seconds.
[10315]: Child process done!!!
[10314] Wake up!, check lock (should be NOT locked!).
[10314] Lock of file '3' is 0.
[10314] Parent Done!!!
- [10314]: Parent process started
- [10314]->[10315] Child forked
- [10314]->[10315] File 'test.out' locked
- [10315]: Child process started
- [10314] Parent forked
- [10314] Sleep 10 seconds.
- [10314] Check lock (should be locked!).
- [10314] Lock of file '3' is 0. (!!!!) ERROR!
- [10314] Sleep 10 seconds.
- [10315]: Child process done!!!
- [10314] Wake up!, check lock (should be NOT locked!).
- [10314] Lock of file '3' is 0.
- [10314] Parent Done!!!
What do I need to add to the new kernel to restore normal work according to POSIX standard?
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 3 posts
- Users browsing this forum: No registered users and 86 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
