Best linux questions in September 2010

Why cant' I return bigger values from main function ?

13 votes

I am trying to return a bigger value like 1000 form my main function, but when I type echo $? it displays 0.

If I return a smaller value like 100 it displays the correct value.

My Code :

int main(void)
{
     return 1000;
}

Is there any limitation on the values which we can return ?

Thanks.

There are two related concepts here: C exit status, and bash return code. They both cover the range 0-255, but bash uses numbers above 126 for it's own purposes, so it would be confusing to return those from your program.

To be safe limit exit status codes to 0-127, as that is most portable, at least that is implied by http://docs.python.org/library/sys.html#sys.exit.

The C exit status is put into the bash $? variable after execution, but bash uses 127 to indicate 'command not found' so you may want to avoid that. Bash reference page.

Bash also uses 128-255 for signals - they indicate the process was killed with a signal: exit code = 128 + signal number. So you might be able to get away with using numbers close to 255 as it unlikely that signal numbers will go that high.

Beyond those common guide-lines there are many attempts to define what different numbers should mean: http://tldp.org/LDP/abs/html/exitcodes.html.

So it you want to return an arbitrary integer from your program, it's probably best to print it to stdout, and capture it with VALUE=$(program) from your bash script.

Which file systems support splicing via Linux's splice(2)?

10 votes

The man page for the splice system call says that splice may fail and set errno to EINVAL if:

Target file system doesn't support splicing; neither of the descriptors refers to a pipe; or offset given for non-seekable device

Which file systems support splicing?

My original answer was partially incorrect, this is a major rewrite.

Linux 2.6.30.10 and below

In Linux 2.6.30.10 and older, splice returns EINVAL when the source or target filesystem does not support splicing. Here are the filesystems that do support splicing:

  • in read mode: adfs, affs, afs, bfs, btrfs, coda, ecryptfs, exofs, ext2, ext3, ext4, fat, fuse, hpfs, jffs2, jfs, minix, nfs, nilfs2, ntfs, ocfs2, omfs, qnx4, reiserfs, smbfs, sysv, ubifs, udf, ufs.
  • in write mode: exofs, ext2, ext3, ext4, jfs, ocfs2, reiserfs, ubifs.

Details follow. Support for splicing in determined in the do_splice_to() function in the "file to pipe" case and in the do_splice_from() function in the "pipe to file" case. It is done by checking whether the relevant struct file_operations contains .splice_read or .splice_write, respectively. In order to produce the above lists of filesystems, I've grepped fs/*/file.c for .splice_read and .splice_write.

Linux 2.6.31 and above

Starting with Linux 2.6.31, all the filesystems support splicing both in read and write modes.

Details follow. When a filesystem does not have .splice_read or .splice_write in its struct file_operations, a fallback function is used: default_file_splice_read and default_file_splice_write, respectively. See do_splice_to() and do_splice_from() for implementations. Note: EINVAL may still be returned for other reasons listed in the documentation.

Custom Linux GUI: Where to begin?

8 votes

I've had a long standing interest in developing an OS UI tailored to my needs and interests. When I was younger, I went crazy playing with the Stardock skinning tools for Windows. I loved developing my own window styles and layout ideas. Since then I've had an unscratchable itch.

  • I'm not particularly interested in fiddling with the lower level kernel operations, just the presentational aspects. I've been considering some flavor of Linux.
  • While I would love to have some basic integrated tools/applications that I create myself, I'm primarily interested in the presentations of basic windowing, toolbars, desktop, and file management.
  • I don't want to be locked out from using existing applications, if possible. I, for example, have no interest in writing my own web browser, but having the ability to work existing tools into a design would be a major plus.
  • My ideas are sometimes very visual in nature, so the ability to produce more complex transparency effects and unusual window shapes would be useful. More-or-less the ability to reproduce the graphic fidelity of current UI designs for OS X or Windows would be ideal.
  • An OS flavor and tools that lets me start with a blank screen and work from the ground up or include basics are encouraged. The idea of a "desktop" in the traditional sense shouldn't be mandatory. Flexibility to do different things is important to me.

What I'm looking for:

I'm interested in what Linux/OS flavors might make sense, what tools / frameworks would be useful for accomplishing the task ( Qt seems to be a popular suggestion here ), and basic info on how / where one might start developing / testing such a UI. I'd also be interested reading about any "personal" UI's that people may have developed.

This is an interest far outside my normal development work, so as a disclaimer, forgive my naivete if I appear to be confused. Corrective insight welcomed.

I realize this is a big question, so thanks to those for taking the time to make suggestions.

You want to build your own DE (desktop environment). Common examples are GNOME and KDE, although more of them were popular. It actually used to be very popular to build your own DE, and dedicated scripting tools were often created.

You will usually need to combine multiple tools: a window manager, a toolbar program, a desktop manager (icons), session manager, possibly more. Out of that only a window manager is a required part (it usually doesn't make any sense not to run any WM inside X server), and others are optional. You will usually not write these tools from scratch (it is a lot of work), but use already available components.

Note that both GNOME and KDE actually consists of these elements (well integrated). For example GNOME consists of a window manager (metacity), toolbars (gnome-panel), desktop manager (nautilus) and so on. You can change one element into another if you want: it used to be popular to use sawfish as a window manager instead of metacity, keeping all the other elements intact. Now it is popular to use compiz instead of metacity.

I used to use FVWM, which is a window manager with an additional (quite good) scripting capabilities that could be used to create toolbars, menus and other things. One of nice examples is FVWM-Crystal, which is a complete DE built on FVWM and few other tools, written in a mix of FVWM scripting and Python. You could actually change any kind of behaviour at runtime by just opening FVWM's scripting console and typing commands. FVWM-Crystal can be a good starting point if you want to start from something already usable; bare FVWM is good if you want to build your DE from scratch.

[UPDATE: it seems that gnome-shell is very similar in this regard to FVWM. Most of its behavior is scripted using JavaScript (instead of a custom language in FVWM), and is very easy to change. It is also very actively developed, as it is an important part of GNOME3, with very good support for composition. It's a hacker's heaven ;-)]

There was a website that was a good source of ideas to implement: lynucs.org. It is down for two years now, but it got archived.

Warning: lots of these components are not maintained any more, especially since GNOME/KDE started to become actually usable. Development in this area is usually driven more by specific requirements of embedded devices: phones or netbooks.

Now, to answer your actual questions:

  • Linux/OS flaver: anything easily customizable: Debian, Arch, Gentoo, LFS...
  • Tools/frameworks: it depends on what do you want to achieve. If you want to write a custom toolbar you might just use some scripting languages (like FVWM's), custom tools like adesklets, or write your own in Qt (if most of your other components is in Qt) or GTK (if most of your other components is in GTK).
  • Personal UIs: there were lots of them, and sites like lynucs.org was a nice compilation of them (lynucs listed components used in each desktop).
  • Complex transparency effects: older tools usually do not handle it natively, or do a simple things like just reusing part of desktop wallpaper as its own background (so-called fake transparency). Most probably you'll need to write your own code, f.e. as a plugin to compiz.

Help me understand the assembly code

8 votes

I am trying to understand the assembly level code for a simple C program by inspecting it with gdb's disassembler.

Following is the C code:

#include <stdio.h>

void function(int a, int b, int c) {
   char buffer1[5];
   char buffer2[10];
}

void main() {
  function(1,2,3);
}

Following is the disassembly code for both main and function

gdb) disass main
Dump of assembler code for function main:
0x08048428 <main+0>:    push   %ebp
0x08048429 <main+1>:    mov    %esp,%ebp
0x0804842b <main+3>:    and    $0xfffffff0,%esp
0x0804842e <main+6>:    sub    $0x10,%esp
0x08048431 <main+9>:    movl   $0x3,0x8(%esp)
0x08048439 <main+17>:   movl   $0x2,0x4(%esp)
0x08048441 <main+25>:   movl   $0x1,(%esp)
0x08048448 <main+32>:   call   0x8048404 <function>
0x0804844d <main+37>:   leave  
0x0804844e <main+38>:   ret
End of assembler dump.

(gdb) disass function
Dump of assembler code for function function:
0x08048404 <function+0>:    push   %ebp
0x08048405 <function+1>:    mov    %esp,%ebp
0x08048407 <function+3>:    sub    $0x28,%esp
0x0804840a <function+6>:    mov    %gs:0x14,%eax
0x08048410 <function+12>:   mov    %eax,-0xc(%ebp)
0x08048413 <function+15>:   xor    %eax,%eax
0x08048415 <function+17>:   mov    -0xc(%ebp),%eax
0x08048418 <function+20>:   xor    %gs:0x14,%eax
0x0804841f <function+27>:   je     0x8048426 <function+34>
0x08048421 <function+29>:   call   0x8048340 <__stack_chk_fail@plt>
0x08048426 <function+34>:   leave  
0x08048427 <function+35>:   ret    
End of assembler dump.

I am seeking answers for following things :

  1. how the addressing is working , I mean (main+0) , (main+1), (main+3)
  2. In the main, why is $0xfffffff0,%esp being used
  3. In the function, why is %gs:0x14,%eax , %eax,-0xc(%ebp) being used.
  4. If someone can explain , step by step happening, that will be greatly appreciated.

The reason for the "strange" addresses such as main+0, main+1, main+3, main+6 and so on, is because each instruction takes up a variable number of bytes. For example:

main+0: push %ebp

is a one-byte instruction so the next instruction is at main+1. On the other hand,

main+3: and $0xfffffff0,%esp

is a three-byte instruction so the next instruction after that is at main+6.

And, since you ask in the comments why movl seems to take a variable number of bytes, the explanation for that is as follows.

Instruction length depends not only on the opcode (such as movl) but also the addressing modes for the operands as well (the things the opcode are operating on). I haven't checked specifically for your code but I suspect the

movl $0x1,(%esp)

instruction is probably shorter because there's no offset involved - it just uses esp as the address. Whereas something like:

movl $0x2,0x4(%esp)

requires everything that movl $0x1,(%esp) does, plus an extra byte for the offset 0x4.

In fact, here's a debug session showing what I mean:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

c:\pax> debug
-a
0B52:0100 mov word ptr [di],7
0B52:0104 mov word ptr [di+2],8
0B52:0109 mov word ptr [di+0],7
0B52:010E
-u100,10d
0B52:0100 C7050700      MOV     WORD PTR [DI],0007
0B52:0104 C745020800    MOV     WORD PTR [DI+02],0008
0B52:0109 C745000700    MOV     WORD PTR [DI+00],0007
-q
c:\pax> _

You can see that the second instruction with an offset is actually different to the first one without it. It's one byte longer (5 bytes instead of 4, to hold the offset) and actually has a different encoding c745 instead of c705.

You can also see that you can encode the first and third instruction in two different ways but they basically do the same thing.


The and $0xfffffff0,%esp instruction is a way to force esp to be on a specific boundary. This is used to ensure proper alignment of variables. Many memory accesses on modern processors will be more efficient if they follow the alignment rules (such as a 4-byte value having to be aligned to a 4-byte boundary). Some modern processors will even raise a fault if you don't follow these rules.

After this instruction, you're guaranteed that esp is both less than or equal to its previous value and aligned to a 16 byte boundary.


The gs: prefix simply means to use the gs segment register to access memory rather than the default.

The instruction mov %eax,-0xc(%ebp) means to take the contents of the ebp register, subtract 12 (0xc) and then put the value of eax into that memory location.


Re the explanation of the code. Your function function is basically one big no-op. The assembly generated is limited to stack frame setup and teardown, along with some stack frame corruption checking which uses the afore-mentioned %gs:14 memory location.

It loads the value from that location (probably something like 0xdeadbeef) into the stack frame, does its job, then checks the stack to ensure it hasn't been corrupted.

Its job, in this case, is nothing. So all you see is the function administration stuff.

Stack set-up occurs between function+0 and function+12. Everything after that is setting up the return code in eax and tearing down the stack frame, including the corruption check.

Similarly, main consist of stack frame set-up, pushing the parameters for function, calling function, tearing down the stack frame and exiting.

Comments have been inserted into the code below:

0x08048428 <main+0>:    push   %ebp                 ; save previous value.
0x08048429 <main+1>:    mov    %esp,%ebp            ; create new stack frame.
0x0804842b <main+3>:    and    $0xfffffff0,%esp     ; align to boundary.
0x0804842e <main+6>:    sub    $0x10,%esp           ; make space on stack.

0x08048431 <main+9>:    movl   $0x3,0x8(%esp)       ; push values for function.
0x08048439 <main+17>:   movl   $0x2,0x4(%esp)
0x08048441 <main+25>:   movl   $0x1,(%esp)
0x08048448 <main+32>:   call   0x8048404 <function> ; and call it.

0x0804844d <main+37>:   leave                       ; tear down frame.
0x0804844e <main+38>:   ret                         ; and exit.

0x08048404 <func+0>:    push   %ebp                 ; save previous value.
0x08048405 <func+1>:    mov    %esp,%ebp            ; create new stack frame.
0x08048407 <func+3>:    sub    $0x28,%esp           ; make space on stack.
0x0804840a <func+6>:    mov    %gs:0x14,%eax        ; get sentinel value.
0x08048410 <func+12>:   mov    %eax,-0xc(%ebp)      ; put on stack.

0x08048413 <func+15>:   xor    %eax,%eax            ; set return code 0.

0x08048415 <func+17>:   mov    -0xc(%ebp),%eax      ; get sentinel from stack.
0x08048418 <func+20>:   xor    %gs:0x14,%eax        ; compare with actual.
0x0804841f <func+27>:   je     <func+34>            ; jump if okay.
0x08048421 <func+29>:   call   <_stk_chk_fl>        ; otherwise corrupted stack.
0x08048426 <func+34>:   leave                       ; tear down frame.
0x08048427 <func+35>:   ret                         ; and exit.

I think the reason for the %gs:0x14 may be evident from above but, just in case, I'll elaborate here.

It uses this value (a sentinel) to put in the current stack frame so that, should something in the function do something silly like write 1024 bytes to a 20-byte array created on the stack or, in your case:

char buffer1[5];
strcpy (buffer1, "Hello there, my name is Pax.");

then the sentinel will be overwritten and the check at the end of the function will detect that, calling the failure function to let you know, and then probably aborting so as to avoid any other problems.

If it placed 0xdeadbeef onto the stack and this was changed to something else, then an xor with 0xdeadbeef would produce a non-zero value which is detected in the code with the je instruction.

The relevant bit is paraphrased here:

          mov    %gs:0x14,%eax     ; get sentinel value.
          mov    %eax,-0xc(%ebp)   ; put on stack.

          ;; Weave your function
          ;;   magic here.

          mov    -0xc(%ebp),%eax   ; get sentinel back from stack.
          xor    %gs:0x14,%eax     ; compare with original value.
          je     stack_ok          ; zero/equal means no corruption.
          call   stack_bad         ; otherwise corrupted stack.
stack_ok: leave                    ; tear down frame.

How to prevent a Linux program from running more than once?

8 votes

What is the best way to prevent a Linux program/daemon from being executed more than once at a given time?

The most common way is to create a PID file: define a location where the file will go (inside /var/run is common). On successful startup, you'll write your PID to this file. When deciding whether to start up, read the file and check to make sure that the referenced process doesn't exist (or if it does, that it's not an instance of your daemon: on Linux, you can look at /proc/$PID/exe). On shutdown, you may remove the file but it's not strictly necessary.

There are scripts to help you do this, you may find start-stop-daemon to be useful: it can use PID files or even just check globally for the existence of an executable. It's designed precisely for this task and was written to help people get it right.

Why mkdir fails to work with tilde (~)?

7 votes

When I write

mkdir("~/folder1" , 0777);

in linux, it failed to create a directory. If I replace the ~ with the expanded home directory, it works fine. What is the problem with using ~ ?

Thanks

~ is known only to the shell and not to the mkdir system call.

But if you try:

system("mkdir ~/foo");

this works as the "mkdir ~/foo" is passed to a shell and shell expands ~ to $HOME

If you want to make use of the $HOME with mkdir, you can make use of the getenv function as:

char path[MAX];
char *home = getenv ("HOME");
if (home != NULL) {
        snprintf(path, sizeof(path), "%s/new_dir", home);
        // now use path in mkdir
        mkdir(path, PERM);
}

Linux tool to check spelling of comments in c/c++ source code

7 votes
What software do you suggest to check spelling of comments contained in c/c++ source code (especially doxygen comments)? I'm looking something that will parse only comments so I can easily find mistakes and correct them. The question is general but to be more specific - I'm using CodeLite IDE.

Emacs has ispell-comments-and-strings which works pretty well from inside the editor. It relies on the syntax highlighting mechanism to identify comments and strings, so it works with any language for which you have good highlighting.

No idea if how you make it work with your IDE.

Extending homework testing platform to include code analysis (C/C++)

7 votes

I'm maintaining/developing a platform for homework testing. It's mostly automatic. What I need to add now is code analysis. I need to check the code for specific constructs.

For example:

Does the file main.cpp contain a class named user with a const method get_name()?

Is there some tool out there that would allow me to do such stuff (ideal would be something that can be scripted). Linux only.

I have discovered dehydra tool from Mozilla. It seems to be mostly written for internal purposes, but it may just be exactly what I was looking for.

https://developer.mozilla.org/En/Dehydra/Using_Dehydra

Edit: Dehydra is great. It is missing some minor features like determining const methods, but otherwise great.

Is it safe to thread after forking?

7 votes

I've learned that you should usually stick with either forking or threading to avoid running into very strange and extremely hard-to-debug problems, so until now I always did exactly that. My problem with the matter is that when I stick with only forking, creating many short-lived processes to distribute chunks of work to gets the more expensive with the more CPU cores I want to feed, up until at some point performance just doesn't scale reasonably anymore. At the same time, using only threads I have to be ever so careful about which libraries I use and generally be extremely defensive with regards to thread-safety, this taking up lots of precious development time and enforcing the waiving of some favourite libraries. So, even though I'm warned, the thought of mixing forking and threading does appeal to me on a number of levels.

Now, from what I read so far, problems always seem to arise when there are already threads created when the fork happens.

Given I designed a system that would start up, daemonize, fork off its main tiers and never did any forking again ever after I'd be perfectly safe and robust. If some of those pre-forked tiers would now start to use threads to distribute their workload over many CPU cores, so that the various child processes never know of the other child's thrads, would that be safe still? I can assure that each tier in itself is thread-safe and that the non-thread-safe tiers won't ever start a thread of their own.

While I feel quite safe about this approach, I'd appreciate a few professional opinions on the matter, pointing out all sorts of possible caveats, interesting points of view, links to advanced reading etc. The language I personally use is Perl on Debian, RedHat, SuSe, and OS X, but the topic should be general enough to be valid for any language on any Un*x/BSD-like platform that would behave remotely POSIXish, maybe even Interix.

Your approach is fine under POSIX, as long as you don't create any MAP_SHARED shared memory regions that are shared among the forked processes. Once the processes are forked, they are independent.

See the POSIX documentation on fork().

Keeping memory usage within available amount

7 votes

I'm writing a program (a theorem prover as it happens) whose memory requirement is "as much as possible, please"; that is, it can always do better by using more memory, for practical purposes without upper bound, so what it actually needs to do is use just as much memory as is available, no more and no less. I can figure out how to prioritize data to delete the lowest value stuff when memory runs short; the problem I'm trying to solve is how to tell when this is happening.

Ideally I would like a system call that returns "how much memory is left" or "are we out of memory yet?"; as far as I can tell, no such thing exists?

Of course, malloc can signal out of memory by returning 0 and new can call a handler; these aren't ideal signals, but would be better than nothing. A problem, however, is that I really want to know when physical memory is running out, so I can avoid going deep into swap and thereby making everything grind to a halt; I don't suppose there's any way to ask "are we having to swap yet?" or tell the operating system "don't swap on my account, just fail my requests if it comes to that"?

Another approach would be to find out how much RAM is in the machine, and monitor how much memory the program is using at the moment. As far as I know, there is generally no way to tell the former? I also get the impression there is no reliable way to tell the latter except by wrapping malloc/free with a bookkeeper function (which is then more problematic in C++).

Are there any approaches I'm missing?

The ideal would be a portable solution, but I suspect that's not going to happen. Failing that, a solution that works on Windows and another one that works on Unix would be nice. Failing that, I could get by with a solution that works on Windows and another one that works on Linux.

I think the most useful and flexible way to use all the memory available is to let the user specify how much memory to use.

Let the user write it in a config file or through an interface, then create an allocator (or something similar) that will not provide more than this memory.

That way, you don't have to find statistics about the current computer as this will allways be biased by the fact that the OS could also run other programs as well. Don't even talk about the way the OS will manage cache, the differences between 32 and 64 bit making adress space limit your allocations etc.

In the end, human intelligence (assuming the user know about the context of use) is cheaper to implement when provided by the user.

In what order does ld-linux.so search shared libraries?

6 votes

When ld-linux resolves a symbol it searches through the shared libraries in a particular order and stops when it finds a shared library with a matching symbol.

What determines the order it searches through the libraries? Does it make a difference if the unresolved symbol is in the main program or in another shared library?

How could I determine the search order programatically without calling external programs like ldd?

From http://www.muppetlabs.com/~breadbox/software/ELF.txt (as mentioned by sarnold):

When resolving symbolic references, the dynamic linker examines the symbol tables with a breadth-first search. That is, it first looks at the symbol table of the executable program itself, then at the symbol tables of the DT_NEEDED entries (in order), then at the second level DT_NEEDED entries, and so on.

Building an USB peripherial

6 votes

I would like to control an RC model via USB from my computer. I don't need a real radio control, so controlling the servos directly through cables is sufficitent (yes, there will be cables between the model and the controlling unit). I thought I would build some microcontroller-based device which would be connected to the computer via USB and the servos would be connected to this device.

I'm asking for some hint where I should start. I know how servos are controlled and how should I eventually program the microcontroller to control the servos, but the thing I really don't know much about is the USB communication neither on the device side nor the computer side (which will be Linux).

I would like to do the progamming in C (maybe Assembler for the microcontroller).

Thanks for every hint.

You might want to start with something like an Arduino, which is a microcontroller on a separate board that you can talk to over USB. There's great development environments and community for Arduino projects.

If you use an FTDI chip alone, you will still need something to understand the RS232 serial instructions from the computer and to control the servo lines. This is where the Arduino will be really helpful.

What C++ IDEs on Linux have "intellisense" in par with, or better, than Visual Studio?

6 votes

There are some Linux based C++ projects in the pipe. What IDEs should I go for that have some kind of "intellisense" in par with, or better, than the one of a bare Visual Studio (that is, without the Visual Assist steroids).

(Note that I didn't use the words "as good as, or better". I consider the Visual Studio C++ intellisense everything but good, hence the "in par with" words and Visual Assist comment).

None. Eclipse and Qt Creator are popular choices, but they have nothing on VS.

struct sockaddr_un v/s sockaddr - C(Linux)

5 votes

How is struct sockaddr different from struct sockaddr_un ?

I know that we use these structures in client-server modules,for binding the socket to the socket address.And we use a cast operator for it to accept struct sockaddr_un.

I want to know how different/similar are they,and why the cast operator?

"struct sockaddr" is a generic definition. It's used by any socket function that requires an address.

"struct sockaddr_un" (a "Unix sockets" address) is a specific kind of address family.

The more commonly seen "struct sockaddr_in" (an "Internet socket" address) is another specific kind of address family.

The cast is what allows the sockets APIs to accept a common parameter type that will actually be any one of several different actual types.

Here's a good link that shows several different address family definitions:

http://www.cas.mcmaster.ca/~qiao/courses/cs3mh3/tutorials/socket.html

GAE " no attribute 'HTTPSHandler' " dev_appserver.py

5 votes

I am trying to use the google appengine python SKD from my ubuntu lucid. I have already compiled python2.5. But when I execute any "dev_appserver.py" command with it I get the following error:

 Traceback (most recent call last):
  File "dev_appserver.py", line 69, in <module>
    run_file(__file__, globals())
  File "dev_appserver.py", line 65, in run_file
    execfile(script_path, globals_)
  File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver_main.py", line 90, in <module>
    from google.appengine.tools import appcfg
  File "/media/Ultimate/WebD/django/app_engine/google_appengine/google/appengine/tools/appcfg.py", line 59, in <module>
    from google.appengine.tools import appengine_rpc
  File "/media/Ultimate/WebD/django/app_engine/google_appengine/google/appengine/tools/appengine_rpc.py", line 24, in <module>
    import fancy_urllib
  File "/media/Ultimate/WebD/django/app_engine/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 328, in <module>
    class FancyHTTPSHandler(urllib2.HTTPSHandler):
AttributeError: 'module' object has no attribute 'HTTPSHandler'

I have checked the urllib2 moduls of python2.6 and python2.5 but there was no difference in the models defination and HTTPSHandelr is there in python2.5 too. So I guess it is some other sort of error.

I tried to run with the default python2.6 too but then I get the following error:

WARNING  2010-09-11 12:08:40,848 datastore_file_stub.py:657] Could not read datastore data from /tmp/dev_appserver.datastore
Traceback (most recent call last):
  File "./dev_appserver.py", line 69, in <module>
    run_file(__file__, globals())
  File "./dev_appserver.py", line 65, in run_file
    execfile(script_path, globals_)
  File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver_main.py", line 449, in <module>
    sys.exit(main(sys.argv))
  File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver_main.py", line 426, in main
    static_caching=static_caching)
  File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver.py", line 3820, in CreateServer
    server = HTTPServerWithScheduler((serve_address, port), handler_class)
  File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver.py", line 3840, in __init__
    request_handler_class)
  File "/usr/lib/python2.6/SocketServer.py", line 400, in __init__
    self.server_bind()
  File "/usr/lib/python2.6/BaseHTTPServer.py", line 108, in server_bind
    SocketServer.TCPServer.server_bind(self)
  File "/usr/lib/python2.6/SocketServer.py", line 411, in server_bind
    self.socket.bind(self.server_address)
  File "<string>", line 1, in bind
socket.error: [Errno 98] Address already in use

It works well in windows and even under wine.

Update
Problem with python2.6 solved.
I had configured my apache server for a django deployment on the 8080 and 80 port some time earlier.

But there is still same error with python2.5 isntallation.

Solved the issue...just needed to build all dependencies of python using:

apt-get build-dep python

python compiles with no error even when all the dependencies are not installed. It just skips the modules which require them and builds python.

Git and hard links

5 votes

Since git does not recognize symbolic links that point to outside of the repository.

is there any problem using hard links ?

Git could break them ? Can point me to detailed information ?

The 'tree' object, representing directories in Git, stores file name and (subset of) permissions. It doesn't store inode number (or other kind of file id). Therefore hard links cannot be represented in git, at least not without third party tools such as metastore or git-cache-meta (and I am not sure if it is possible even with those tools).

Git tries to not touch files that it doesn't need to update, but you have to take into account that git doesn't try to preserve hardlinks, so they can be broken by git.


About symbolic links pointing outside repository: git has no problems with them and should preserve contents of symbolic links... but utility of such links is dubious to me, as whether those symlinks would be broken or not depends on the filesystem layout outside git repository, and not under control of git.

opengl es 2.0 on linux

5 votes

I would like to develop openGLES 2.0 apps on my ubuntu machine. I could not find any libraries/emulators that support ES 2.0 yet. Any suggestions?

You can use POWERVR SDK to emulate Opengl es on your PC. You can download the SDK here. The archive provides the necessary steps to install the emulation libraries as a documentation file and includes tutorials and demo applications with source codes.