Operating System - HP-UX
1827713 Members
2878 Online
109967 Solutions
New Discussion

Re: Anamolous behaviour with multiple sessions.

 
Purusa
Frequent Advisor

Anamolous behaviour with multiple sessions.

When I open different sessions in the same directory path, I get different behaviour while deleting the directories.
The problem is like this:
I log in one path: /abc/xyz/kkk
Then I try to uninstall all the software present in the workstation including the parent directory itself i.e. /abc/xyz/kkk.I have code whereby I detect presence of this directory path and pop-up messages corresponding to presence or absence of this directory path.
In case only a single user is logged on the in this path(i.e user who is uninstalling the software), behaviour is ok. But in case of two or more users logged in the same path the behaviour is not as expected.The directory structure gets deleted in all the test cases.
Can someone give some explanation of this behaviour.

Thanx in advance,
Regards,
Pankaj
A deep chasm can't be crossed in two steps
15 REPLIES 15
Elmar P. Kolkman
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

I'm not sure I understand... If multiple users are logged in, what happens and what would you expect???
Every problem has at least one solution. Only some solutions are harder to find.
Todd McDaniel_1
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

I think you are asking this:

Why even though a second user can cd /abc/xyz/kkk and you can still remove the software and the directory while someone is in the directory?


___________________________
I think the behavior you are looking for is that the uninstall process would fail to uninstall and also fail to remove the directory b/c of the user in the named directory.


The action you are expecting I think is similar to the umount command where the filesystem is busy. OS functions are smart in HPUX, so as dis-allow you to umount a filesystem in use or where a user is active in it. I dont think the swinstall function allows for a check to see if anyone may be in a directory.

I dont think this is the same as the umount command. Removing software has no such checks to see who or what id is active in a certain directory.

However, with that said, I would expect some complaint that a user is active or something similar.

What happens to the user? Are they disconnected or merely dropped to a lower lvl directory?

Hope this helps.
Unix, the other white meat.
Michael Schulte zur Sur
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Hi,

But in case of two or more users logged in the same path the behaviour is not as expected

That means? Are you using rm to uninstall the software, or how do you do it?

greetings,

Michael
Purusa
Frequent Advisor

Re: Anamolous behaviour with multiple sessions.

Hi all,

Thanx for the prompt answers/suggestions provided.
I am using "rm" to uninstall the software.
In all the scenarios the parent directory from where I run the script gets deleted.

I have a piece of code which is like this:
if [ ! -d /abc/xyz/kkk ];
then
"pop-up error msg"

So when two users are logged in the same directory path, although directory structure has been deleted still this message is being displayed.
With single user logged in and uninstalling the software, the behaviour is ok i.e. this error message is not popped up. I hope the problem is clear now.
A deep chasm can't be crossed in two steps
Massimo Bianchi
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Th problem lies in the logic of the script, is not meant to be multi user.

If multiple users should be able to use it, you must ensure that everything id not duplicated, including directory names.

For example, you can use that directory as a base, but each process MUST use a unique subdirectory, choosen at runtime.

I suggest you to create some code with the $$ buil in variable, that is the PID number, unique as sufciente.

[-d /yourdir ] && "mkdir /yourdir/workset_$$"


And then install from the workset_$$

Massimo
Purusa
Frequent Advisor

Re: Anamolous behaviour with multiple sessions.

Hi Massimo,

I understand that the script is not meant for multi users but I wanted to know the root cause of the problem.
Why is there anamolous behaviour? Is it something internal to Unix or what???

Regards,
Pankaj
A deep chasm can't be crossed in two steps
Michael Schulte zur Sur
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Hi,

I have a piece of code which is like this:
if [ ! -d /abc/xyz/kkk ];
then
"pop-up error msg"

So when two users are logged in the same directory path, although directory structure has been deleted still this message is being displayed.

After you've deleted the directory structure, the message should pop up, because it does not exist anymore. There is however an inconsistency in some shells, which allow you to delete a dir, which is your current one. The best way to avoid this, is of course to run it from somewhere else.

can you check, what I said?

Michael
John Carr_2
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Hi

try using fuser command to see if anything is attached to the directory before using the rm command.

fuser -c /dir_to_delete

:-) John.
Purusa
Frequent Advisor

Re: Anamolous behaviour with multiple sessions.

Hi Michael,

While deleting the directory structure, I first go to root / directory and delete the directories.
But the main problem is that the piece of code
if [ ! -d /abc/xyz/kk ]; then
"pop up error msg"

does NOT pop up error msg with single user logged on and uninstalling the software.
However, the same piece of code POPS UP error msg with two users logged on.

The behaviour shd be consistent i.e. error msg in both the scenarios or no error msg in both the scenarios.

Regards and Thanx,
Pankaj.
A deep chasm can't be crossed in two steps
Umapathy S
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Ignoring multiple users, what happens or what you get when you run the script second time. Do you get any errors like directory not found.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Michael Schulte zur Sur
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Hi,

btw, what shell are you using?

Michael
Purusa
Frequent Advisor

Re: Anamolous behaviour with multiple sessions.

I am using Bourne shell.
Running script 2nd time is of no help as by that time all the software has been already uninstalled and directories are removed.
Regards and Thanx
Pankaj
A deep chasm can't be crossed in two steps
Umapathy S
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Pankaj,
Are the multiple sessions executed at the same time. There might be a chance that the dirs were intact when all the users invoke that script.

If the script throws error the second time it is run then it is along the lines of expected behaviour. Try running the script with user A and after some time with user B.

Can you post the script here?

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Purusa
Frequent Advisor

Re: Anamolous behaviour with multiple sessions.

Following is the script;

uninstall_software
---------------------------------------
function aa()
cd /
rm -rf /abc/xyz/kkk

function bb()
if [ ! -r /abc/xyz/kkk ];
then
echo "popup error msg"
fi
---------------------------------------
#script execution order
bb
aa

These functions are called recursively for a number of software components.


Script is present in the path /abc/xyz/kkk
Now, there are 2 users logged in same path at same time and User 2 executes the script:

User 1:
#cd /abc/xyz/kkk
#ls
uninstall_software

User 2:
#cd /abc/xyz/kkk
#./uninstall_software

So after one user executes the script the script as well as the directory structure is gone. Hence I could not understand how to execute the script again.
A deep chasm can't be crossed in two steps
Michael Schulte zur Sur
Honored Contributor

Re: Anamolous behaviour with multiple sessions.

Hi,

thanks for posting the script. This makes it a bit clearer.

I have a number of comments.
1. The body of a function must be delimited by {}.
2. When you call a script and a cd is made in this script, you do not actually leave the directory.
3. use rm without -f to see errors.

greetings,

Michael