What is the relationship between `launchctl limit` and `ulimit`? There is not any ulimit configuration in system startup files/ shell startup scripts.

ulimit -a shows:

-u: processes                       1064
-n: file descriptors                256


launchctl limit shows:

maxproc     2048           2048           
maxfiles    2048           2048


I vaguely remember that launchctl's limits should match with a shell's ulimit output, I might be wrong.

Is there any relationship between the lauchctl's limits and ulimit?
In the shell, ulimit provides "control over the resources available to the shell and to processes started by it" (see man bash). Therefore, it applies only to the shell and its children. The limits for launchd are related to it and the processes that it manages. The two are separate.

Individual programs can set their own resource limits by calling the Standard C Library routines ulimit() or getrlimit() and setrlimit(). Certain resource limits cannot be elevated unless the process is running as the super-user.

As a practical example, I debug large software projects and the shell's default limit for the number of open files isn't big enough. In my .bashrc file, I have the following:

# Increase the upper limit on the number of open files:
ulimit -n 1024


Now my debugger won't complain that it can't open all the files it needs. Obviously, this should have no impact on launchd.