maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Wierd Crash (https://talk.maemo.org/showthread.php?t=46200)

Figa 2010-03-01 15:16

Wierd Crash
 
Hi, when I run this code program crash. In scratchbox is all ok but in real device no. File save.txt is saved in /home/usr/.app/
Code:

FILE *file = fopen("/home/usr/.app/save.txt","w");
I tryed, but It crash too.
Code:

FILE *file = fopen("save.txt","w");
What is wrong? THX fr your replies.

jaeezzy 2010-03-01 15:44

Re: Wierd Crash
 
Are you sure its this line thats causing the trouble? Are you checking the returned pointer "file"? BTW, I think you are trying to write "/home/user...." whats the error message?

Figa 2010-03-01 16:06

Re: Wierd Crash
 
I am sure. I dont know what return file because app crashed. Thx for your time.

spanner 2010-03-01 16:10

Re: Wierd Crash
 
Quote:

Originally Posted by Figa (Post 551146)
I am sure. I dont know what return file because app crashed. Thx for your time.

If you are sure, then this:

Code:

#include <stdio.h>
int main()
{
  FILE *file = fopen("/home/usr/.app/save.txt","w");
}

will also crash. Please test this. If it crashes, then I am sure someone will help you. If it doesn't, then you haven't provided enough information.

Figa 2010-03-01 17:35

Re: Wierd Crash
 
fopen doesnt open this file and pointer is empty. I am sure that the file exists. Where is problem?

spanner 2010-03-01 17:47

Re: Wierd Crash
 
Quote:

Originally Posted by Figa (Post 551297)
fopen doesnt open this file and pointer is empty. I am sure that the file exists. Where is problem?

Where? I suspect between chair and keyboard. Didn't you read jaeezzy's post pointing out that you're writing "/home/usr" rather than "/home/user"?

If you really have created a directory called /home/usr/.app (why would you do that?), then:
a) sorry
b) please don't release an app that writes to this crazy location
c) paste the output of the command
Code:

ls -l -R /home/usr/.app
so that we can check for appropriate file permissions

Figa 2010-03-01 18:09

Re: Wierd Crash
 
-rw-r--r-- 1 root root 0 Feb 16 14:48 candidates.txt
-rw-r--r-- 1 root root 0 Feb 16 14:52 resources.rcc
-rw-r--r-- 1 root root 0 Feb 16 14:54 save.txt

spanner 2010-03-01 18:20

Re: Wierd Crash
 
OK, 2 more questions:
1) are you running the app as 'root', or as 'user'?
2) can you also paste the output of the command
Code:

ls -l -d /home/usr/.app

Figa 2010-03-01 18:41

Re: Wierd Crash
 
As user.
drwxr-xr-x 2 root root 4096 Mar 1 18:35 /home/usr/.app

THX /home/user/.app is better?

spanner 2010-03-01 18:50

Re: Wierd Crash
 
Quote:

Originally Posted by Figa (Post 551394)
As user.
drwxr-xr-x 2 root root 4096 Mar 1 18:35 /home/usr/.app

The ls output shows that you have created the directory /home/usr/.app (and the files within it) as root. So neither the directory, nor the files in it, have write access for 'user'.

if you do
Code:

chown -R user.user /home/usr/.app
to change ownership of the files, you'll find that 'user' now has access to them.

Quote:

Originally Posted by Figa (Post 551394)
THX /home/user/.app is better?

Yes, much better. That's the normal place to put application config information, and it goes on the same partition as /opt, so it doesn't use space on the root filesystem.


All times are GMT. The time now is 21:05.

vBulletin® Version 3.8.8